next up previous contents
Next: Lists Up: Other useful things to Previous: Footnotes

Tables

LATEX has a simple method for generating all sorts of tables. You give it one command to tell it how to set up the table and then give it the data. You specify how many columns the table is going to have, what to do to the data within each column as well as how to separate each column. When you enter the data you give one row at a time. Each data field is separated by ``&'' and the end of a row is signaled by ``\\''. Here are several examples of what is possible and how to create them.

a b c
aa bb cccccc
aaa bbb ccc

This is a table with three columns. In the first column the data are centered, in the second they are left justified and in the third they are right justified. This was done by entering {clr}. Changing what is in these curly braces changes the number of columns and how each one is formatted. The previous example was created with the following text. Notice that the line breaks in the typed text make no difference to LATEX. Rows are separated by the \\ character and the columns within the rows are separated by the & character.

\begin{tabular}{clr}
a& b& c\\ aa& bb& cccccc\\
aaa& 
bbb& ccc\\
\end{tabular}

You can also have boxes around the table and lines separating the columns if you like. LATEX will put vertical lines wherever you put a | in the column specifications. LATEX has two commands for creating horizontal lines in tables. \hline creates a horizontal line across the whole table. \cline{m-n} creates a horizontal line from the beginning of column m to the end of column n.

a b c
aa bb cc
aaa bbb ccc

This was created using the following commands:

\begin{center}
\begin{tabular}{||c|l||r||}\hline
a& b& c\\ \cline{2-3} aa& bb& cc\\ \hline
aaa& 
bbb& ccc\\ \hline\hline
\end{tabular}
\end{center}


next up previous contents
Next: Lists Up: Other useful things to Previous: Footnotes
Alex Rolfe
1999-10-29