Posting more than one line in LaTeX

topsquark

Forum Staff
We have had an issue in some posts where we go over the 5 image limit. (I'd ask for this limit to be extended, but I don't want to waste my breath.)

Fortunately there is a solution thanks to Moo over on MHF.

The solution uses the "array" command:
\begin{array}{lll} x^2 + y^2 = r^2 \\ x = r~cos(\theta) \\ y = r~sin(\theta) \end{array}

The {lll} tells the complier to align each (of the three) line to the "left." You can also use a "c" to center a line.

This line gives:
$image=http://latex.codecogs.com/png.latex?%5Cbegin%7Barray%7D%7Blll%7D%20x%5E2%20+%20y%5E2%20=%20r%5E2%20%5C%5C%20x%20=%20r%7Ecos%28%5Ctheta%29%20%5C%5C%20y%20=%20r%7Esin%28%5Ctheta%29%20%5Cend%7Barray%7D&hash=97a9e44d4d6302b76f027b635268ca23$

If we use, say, the matrix command the lines are somewhat centered. Using this we can write multiple lines without using more than one image.

-Dan

Unknown008

PHF Hall of Honor

And actually, having only 1 column would require only 1 l, unless it's different here, which I don't think is the case.

Anyway, in case you want your equations to be left aligned, you edit that like this:

\begin{array}{lcr}
Stuff in left column & Stuff in central column & Stuff in right column \\
\end{array}

This would give a table without any border, with 3 columns, the first column being left aligned, the central column being centre aligned and the right column being right aligned. Then the '&' tells the latex to move to the next column while the \\ tells the latex to switch row.

Otherwise, for a table with borders, you can do this:

\begin{array}{|l|c|r|} \hline
Stuff in left column & Stuff in central column & Stuff in right column \\ \hline
\end{array}

The modulus (|) creates vertical borders (in this example, they border all the columns), and the \headline creates a horizontal border above the current row.

topsquark