(URL http://www.cs.cornell.edu/Info/Misc/LaTeX-Tutorial/Tables.html)
\documentstyle commands. It appears next
to the 12pt specification you have been using throughout
this tutorial.
\documentstyle[12pt,fullpage]{article}
That will set the margins to about 6.5 x 8.9 inches.
\documentstyle[12pt,fullpage,doublespace]{article}
Note that this does not doublespace footnotes or figures and tables. If the spacing is too wide, you can put the following command in your preamble:
\setstretch{1.7}
That will decrease the stretch between lines. The setstretch in double spacing is normally set to "2." If you change it to "1," you will be back into single spacing again.
You can create a single spaced environment by using:
\begin{singlespace}
\end{singlespace}
Note that the singlespace environment is not valid unless the doublespace style option has been used.
Use the file called down.tex that you created earlier and make it doublespaced. While you are at it, make the two parts into separate paragraphs.
Here's the dvi output.
We will cover the basic functions of tabular in this section of the tutorial.
You input a table in a \begin{tabular}
environment. The alignment of the columns is specified in the
environment command. The rows are separated by a line break
\\, and the columns are separated by an
&. For example, the following yields
these results.
\begin{tabular}{rrr}
This & Here & And the \\
is & is second & third is \\
first & column & here \\
\end{tabular}
In this example there are three columns which are all
aligned on the right {rrr}. Columns
can be aligned according to the following options:
Take the above example of the tabular environment and change the column alignments three times, stopping to format and preview the results each time.
Use the \bigskip command to try to get some
more space between the sections.
Here's the dvi output.
If you look at the output of the previous examples, you will notice
that the columns are not separated by much space. You can
add horizontal space between columns by using the
\hspace{width} command in
the table setup. For example to add 1 inch between the
columns of a table, use the following construct:
\begin{tabular}{r{\hspace{1in}}rr}
\end{tabular}
Take the updated tab.tex file and add 1 in of horizontal space between each of the columns. Then format it and preview the results.
For the rest of the work to be done with tables, we will use the goal document tables.tex. The final document looks like this. To get tables.tex so you can modify it in the next few exercises, make sure you are in your "latex" directory and copy the file from ~denise/LaTeX/Samples/tables.tex into that directory.
There are two tables in the goal document tables.tex. Make the first table a 2-column table and the second a 4-column table. Do your best to guess the column alignment options.
The document will not look anything like the goal document yet, but don't worry about that at this time.
Here is the dvi output.
You can put tabular text \begin{tabular}
inline like this \end{tabular}, or you can center it.
To center it you would use the \begin{center}
environment followed by the
\begin{tabular} environment, as in:
\begin{center}
\begin{tabular}
. .
\end{tabular}
\end{center}
Rather than using c or l or r to define the columns of the table,
use p{width} which will create
a column width wide where you can input a paragraph
of text.
\begin{tabular}{p{1in}p{2in}}
The previous example creates two columns, of which the left is one inch wide, and the right is two inches wide.
In tables.tex, make the description column of the first table a paragraph which is 3 1/2 inches wide. Make the first column of the second table 2.2 inches wide. Center both tables.
Here is the dvi output.
\hline puts a line
after any row of a table. It can be used only at the start of
a line or just after a row separator (\\). For example, the
following input file produces
these results.
\begin{tabular}{rrr}
\hline
This & Here & And the \\
\hline
is & is second & third is \\
\hline
first & column & here \\
\hline \hline
\end{tabular}
\begin{tabular}{|r|r|r|}
\hline
This & Here & And the \\
\hline
is & is second & third is \\
\hline
first & column & here \\
\hline \hline
\end{tabular}
which produces these results.
\cline{m-n}
command. In the format of the command,
m starts the line in column
m, and n ends the
line in column n. Obviously,
n must be greater than or equal to
m, and both m and
n are required by the command.
Therefore,
\begin{tabular}{|r|r|r|}
\hline
This & Here & And the \\
\cline{1-2}
is & is second & third is \\
\cline{1-1} \cline{3-3}
first & column & here \\
\hline \hline
\end{tabular}
In tables.tex, put the lines around both tables. Then, in the second table, include the pair of lines that cross just the column headed by E2.
Here is the dvi output.
Now, put the double lines under the column headings of the second table, and then add the extra line separating the last row of the second table and preview the results.
Here is the dvi output.
\multicolumn command in your
table. The format for the command is:
\multicolumn{n}{code}{text}
What it does is replace the next n columns with one column. The new column is aligned as the code which is one of r, l, or c. You can use vertical bars within multicolumn alignments as well. The text to be placed in the column goes in text. Consider the following:
\begin{tabular}{|r|r|r|}
\hline
This & Here & And the \\
\cline{1-2}
\multicolumn{3}{|c|}{$x+y=3$} \\
\cline{1-1} \cline{3-3}
first & column & here \\
\hline \hline
\end{tabular}
which produces this table.