Posting more than one line in LaTeX

topsquark

Forum Staff
Apr 2008
3,106
659
On the dance floor, baby!
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:


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
Jun 2010
609
137
Mauritius
Yes, I've thought about this some time ago too :p

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.
 
  • Like
Reactions: topsquark