Math & ScienceFormula Conditional

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
ArataFan
Posts: 5
Joined: Tue Jan 22, 2013 8:43 pm

Formula Conditional

Post by ArataFan »

Sorry everyone, but I tried to search many sites but no result. I want to write equation like the attached one.

Thanks so much
Attachments
formula-conditional-01.jpg
formula-conditional-01.jpg (9.64 KiB) Viewed 29148 times
formula-conditional-02.jpg
formula-conditional-02.jpg (14.75 KiB) Viewed 29148 times
Last edited by localghost on Tue Jan 22, 2013 9:05 pm, edited 1 time in total.
Reason: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Formula Conditional

Post by localghost »

The first equation is nothing special and can be typeset as usual in an {equation} environment. The second one would need the empheq package for the brace on the left side.


Best regards and welcome to the board
Thorsten
ArataFan
Posts: 5
Joined: Tue Jan 22, 2013 8:43 pm

Formula Conditional

Post by ArataFan »

Many thanks for your help, you are very kind to me. But I still can't solve my problem.

I used {equation} environment like this:

Code: Select all

\begin{equation}
Th(flow1) = Th(flow2) =  G, if G < \frac{B}{3}
\end{equation}
And the result is displayed as formula (3.1)

The second one need the empheq package but I dont know how to install additional package in LateX, I searched in wiki, but I dont understand.

Moreover, I'm using LateX in windows7, when I want to extract file to .pdf, I must write text in .txt document, then I type "platex filename.txt", then "dvipdfmx filename.dvi" in C command. This is so difficult to check .pdf file before they become finished.

Please help me, thank you!
Attachments
formula1.jpg
formula1.jpg (9.46 KiB) Viewed 29123 times
Last edited by Stefan Kottwitz on Mon Jan 28, 2013 1:53 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Formula Conditional

Post by cgnieder »

If you have pieces of text in an equation you should use amsmath's \text{} macro to mark them correspondingly:

Code: Select all

% preamble:
% \usepackage{amsmath}
\begin{equation}
 Th(\text{flow1}) = Th(\text{flow2}) =  G, \text{ if } G < \frac{B}{3}
\end{equation}
(I don't actually know if »flow1« and »flow2« should be text here. They looked like it...)

Regards
site moderator & package author
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Formula Conditional

Post by Stefan Kottwitz »

I guess at least the amsmath package is installed on your computer, since this is standard for good math typesetting.

A personal opinion first, I would write Th and flow1 in upright letters, since italic letters are used for variables, operators and text commonly upright. Definign a macro or an operator would be convenient. So my text would be

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\Th}{Th}
\DeclareMathOperator{\flow}{flow}
\begin{document}
\begin{equation}
  \Th(\flow_1) = \Th(\flow_2) =  G, \text{ if } G < \frac{B}{3}
\end{equation}
\end{document}
The brace before the equation could be done without empheq, with \left\{ and \right. and an aligned environment (of amsmath):

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\Th}{Th}
\DeclareMathOperator{\flow}{flow}
\begin{document}
\begin{equation}
  \left\{
  \begin{aligned}
    \Th(\flow_1) &=  G \\
    \Th(\flow_2) &= \ldots
  \end{aligned}
  \right.
\end{equation}
\end{document}
equation.png
equation.png (2.27 KiB) Viewed 29121 times
Stefan
LaTeX.org admin
ArataFan
Posts: 5
Joined: Tue Jan 22, 2013 8:43 pm

Formula Conditional

Post by ArataFan »

Thank you very much for your help, I solved my problem.

First opinion, I know the {equation} environment but the most thing I want here is the space between , and if. This is my code:

Code: Select all

\begin{equation}
Th(\text{flow1}) = Th(\text{flow2}) = G, \:\:\:\:\:\:\:\text{if} \:\:\:G < \frac{B}{3}
\end{equation}
The result is shown as attached formula (3.1)

Second opinion, special thanks to Stefan_K for teaching me aligned environment. Here is my code:

Code: Select all

\begin{equation}
\left\{
\begin{aligned}
Th(\text{flow1}) &= G \\
Th(\text{flow2}) &= \dfrac{B-G}{2} 
\end{aligned}
\right.
\:\:\:\:\:\text{if} \:\:\:\dfrac{B}{3} \leq G < B_1 - B_2
\end{equation}
The result is shown as the attached formula (3.2)

Moreover, my PC can't run this command \DeclareMathOperator but it's ok :)
Attachments
formula2.jpg
formula2.jpg (13.34 KiB) Viewed 29111 times
formula1.jpg
formula1.jpg (9.21 KiB) Viewed 29111 times
Last edited by localghost on Tue Jan 29, 2013 10:48 am, edited 1 time in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Formula Conditional

Post by localghost »

ArataFan wrote:[…] The second one need the empheq package but I dont know how to install additional package in LateX, I searched in wiki, but I dont understand. […]
This is a bit fuzzy. Therefore some questions.
  • What did you try to install the package? Package installation is usually by the package manager of your TeX distribution. What exactly does not work?
  • Which wiki do you mean? A TeX distribution usually has a manual where its handling is explained. What exactly did you not understand?
Precise answers to these questions would be very helpful.
ArataFan
Posts: 5
Joined: Tue Jan 22, 2013 8:43 pm

Formula Conditional

Post by ArataFan »

First, I downloaded full .dtx file in this site: http://ctan.org/tex-archive/macros/latex/contrib/mh
Then, I read how to install .dtx package in this site: http://en.wikibooks.org/wiki/LaTeX/Inst ... a_Packages
I couldn't install, so when I type

Code: Select all

    \documentclass{article}
    \usepackage{empheq}
    \begin{document}
    \begin{equation}
      Th(flow1) = Th(flow2) =  G, \text{ if } G < \frac{B}{3}
    \end{equation}
    \end{document}
Last, I type "platex fiename.txt" in C command, and this is the result:
LaTeX Error: File 'empheq.sty' not found.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Formula Conditional

Post by localghost »

ArataFan wrote:First, I downloaded full .dtx file in this site: http://ctan.org/tex-archive/macros/latex/contrib/mh
Then, I read how to install .dtx package in this site: http://en.wikibooks.org/wiki/LaTeX/Inst ... a_Packages
I couldn't install […]
So I ask once again: Why don't you just use the package manager of your TeX distribution to install packages?
ArataFan
Posts: 5
Joined: Tue Jan 22, 2013 8:43 pm

Formula Conditional

Post by ArataFan »

localghost wrote: So I ask once again: Why don't you just use the package manager of your TeX distribution to install packages?
Sorry, I don't know how to use the package manager of TeX, this is the most important thing I want to tell. Can you teach me how to use this one?
Post Reply