Professional Documents
Culture Documents
Figtab Handouts PDF
Figtab Handouts PDF
Positioning Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Defining Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Ending Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figures and Tables in a LATEX Document
Horizontal Lines Between Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Making a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
RSI 2012 Staff
Table of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Including a Graphic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Scaling Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Scaling Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Distortion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Captions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
\begin{table}[htbp]
Caption Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 ... stuff here ...
Labeling Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 \end{table}
Laying out graphics using tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
b (Bottom) Place the table at the bottom of the The table itself is defined by the tabular environment. The
current page. syntax for this is:
h (Here) Place the table at the spot where the table
environment appears in the text
p (Page) Place the table at the top of the next page. \begin{table}[htbp]
t (Top) Place the table at the top of the current \begin{tabular}{column specification}
page. ... Table stuff in here ...
\end{tabular}
The first letter inside brackets has highest priority. In the \end{table}
example on the previous page, if LATEX couldn’t put the table or
figure “here,” it tried to put it at the top of the current page,
then on the bottom of the current page, then at the top of the
next page.
2 3
4 5
Example Column Specifications
Separating Cells in a Row
Specification: What It Does:
Table cells in a row are separated with &. There should be no &
{ccc} Three columns, all centered, no vertical
after the last cell in a row. Example one-row table:
lines
6 7
Ending Rows
Table rows are ended with \\. There should be a \\ at the end Horizontal Lines Between Rows
of each row. Example two-row table:
\hline puts a horizontal line before or after a row.
\begin{table}[htbp]
\begin{tabular}{lrc}
\hline\hline puts two horizontal lines before or after a row.
Row 1, Cell 1 & Row 1, Cell 2 & Row 1, Cell 3 \\
Row 2, Cell 1 & Row 2, Cell 2 & Row 2, Cell 3 \\
Pop Quiz! Do you know what \hline\hline\hline does?
\end{tabular}
\end{table}
8 9
Making a Table Table of Tables
\begin{table}[htbp]
\begin{tabular}{|l||c|c|} \hline\hline \begin{tabular}{|c||c|c|} \hline
Ice Cream Store & Location & How to Get There \\ \hline %%%%%% Title row starts here
Toscanini’s & Central Square & Just walk! \\ & A & B \\ \hline\hline
Herrell’s & Harvard Square & Red Line \\ %%%%%% Row Foo starts here
A B
J.P. Licks & Davis Square & Red Line \\ Foo &
1 2
Ben \& Jerry’s & Newbury Street & Green Line \\ \hline\hline 2 5 \begin{tabular}{c} 1 \\ 2 \\ 3 \\ 4 \\
Foo \end{tabular} &
\end{tabular} 3 9
\end{table} 4 8 \begin{tabular}{c} 2 \\ 5 \\ 9 \\ 8 \\
1 31 \end{tabular} \\ \hline
2 23 %%%%%% Row Bar starts here
Gives us: Bar
3 16
Bar &
4 42
Ice Cream Store Location How to Get There \begin{tabular}{c} 1 \\ 2 \\ 3 \\ 4 \\
Toscanini’s Central Square Just walk! \end{tabular} &
Herrell’s Harvard Square Red Line \begin{tabular}{c} 31 \\ 23 \\ 16 \\ 42 \\
J.P. Licks Davis Square Red Line \end{tabular} \\ \hline
Ben & Jerry’s Newbury Street Green Line
\end{tabular}
10 11
Bitmap
Viewing and editing graphics
Bitmap
• .png and .tiff: highest quality
• xv: viewing
• .jpeg: good for photos, uses little space
• gimp: editing
• .gif: good for line drawings, limited to 256 colors (NOT
supported by LATEX)
Vector
Vector
• gv: viewing .ps files
12 13
Example of an Included Graphic
\begin{figure}[htbp]
\includegraphics{house.pdf}
Including a Graphic
\end{figure}
14 15
Scaling Example
Usage: \includegraphics[scale=0.7]{house.pdf}
16 17
Distortion
Setting Width and Height
There is no need to set both the width and height—the
Tired of trying to guess scale factors to get your figure to be dimension you do not specify will be scaled to keep the picture’s
just the right size? Use the height or width optional argument proportions correct. If you set both, you might get something
to \includegraphics. like:
Usage: \begin{figure}[htbp]
\includegraphics[height=1in,width=5in]{house.pdf}
\includegraphics[height=2in]{house.pdf} \end{figure}
\includegraphics[width=6cm]{house.pdf}
A popular setting for width is \textwidth. This makes your figure Which will give you:
be the exact width of the page. Example:
\includegraphics[width=\textwidth]{house.pdf}
18 19
Rotating Graphics
Your graphic looks like it lay down to take a nap. Now what?
Centering Tables and Figures
Use the angle optional argument. The image will be rotated by
a corresponding angle counterclockwise.
To center a table or figure, put the tabular environment
or \includegraphics command respectively inside a center
\begin{figure}[htbp]
\includegraphics[angle=90]{house.pdf} environment. Examples:
\end{figure}
\begin{table}[htbp]
Will give you:
\begin{center}
\begin{tabular}{ccc} \begin{figure}[htbp]
Tom & Dick & Harry \\ \begin{center}
Mary & Cathy & Anne \\ \includegraphics{house.pdf}
\end{tabular} \end{center}
\end{center} \end{figure}
\end{table}
20 21
Captions
Caption Example
A figure or table without a caption feels lonely. All figures and
tables should have captions. Use the \caption command for this \begin{figure}[htbp]
purpose. \begin{center}
\includegraphics{house.pdf}
Example: \end{center}
\caption{This is a pretty little house.}
\begin{table}[htbp] \end{figure}
\begin{center}
\begin{tabular}{ccc}
Tom & Dick & Harry \\
Mary & Cathy & Anne \\
\end{tabular}
\end{center}
\caption{Here are some names.}
\end{table} Figure 5: This is a pretty little house.
22 23
24 25
Table of Figures!
Laying out graphics using tables
Time Distorted House
Piano player roll Compact disc
1 s
3 s
26 27
! Paragraph ended before \@array was complete. See the LaTeX manual or LaTeX Companion for explanation.
<to be read again> Type H <return> for immediate help.
\par ...
l.11
l.7 \begin{tabular}{ccf}
?
?
This most likely means you forgot to end the column
specification with a }. This means you used an invalid letter to designate a column
time in the column specification. In the case shown, the culprit
In this case the error occurred in line 11. is the “f” following the two c’s
28 29
Common Table Errors
Common Table Errors
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate Runaway argument?
{The example table caption \end {table} \par This is the paragraph af\ETC.
! File ended while scanning use of \@xdblarg.
l.8 a & b & c & <inserted text>
\par
\\ <*> paper.tex
? \nonstopmode\input
?
This means that you have an extra & in a row. In the case that
This means that you forgot to end a table caption with a }.
generated the error, the table is defined to have three columns,
Notice that there is no line number listed. If you get this error,
so there should be only two ampersands per row.
you will have to check all your captions to make sure they are
OK.
The extra & could be caused by forgetting the \\ at the end of
a row.
30 31
32 33