Archive

Posts Tagged ‘mathmode’

LaTeX Tip of the Day – cases

January 30th, 2009

If you want to define a piecewise equation in your typeset math, or if you want to express a conditional statement, or just group a set of related equations in math mode, then you’re looking for the cases environment. It’s the way to get that big curly brace on the left of a couple of lines of math. In math mode, the code

f(x,y)=\begin{cases}
0 &\text{for~}x\leq 0\,,\\
\sin x+\phi &\text{for~}x > 0\,.
\end{cases}


will produce the output:
$$f(x,y)=\begin{cases}0 &\text{for }x\leq 0\,,\\ \sin x+\phi &\text{for }x > 0\,. \end{cases}$$

Note that you use an alignment character (&) on each line, and the first character after it on each line will align vertically (it’s as if you’re making a 2-column table). Each line ends with \\ save the last one.

This entire construct only gets one equation number (if you have equation numbering on), and you can’t specify the alignment of the first part of each line. Both of these problems are solved by the cases package.

Typesetting , ,

LaTeX Tip of the Day – \text{}

January 23rd, 2009

In math mode, to get roman text (not italicized), use the command text{}. This is useful for units, which should always be set in a roman font:



The \text{} command is also useful (actually necessary) for sub- and superscripts which are whole words or abbreviations:

Typesetting , ,