% created by (unknown)
% modified by ntoro
% modified by edboas 06/24/2003
% modified by cmihelic 06/25/2003
% modified by vivek,semenko,niffer,jasonchu 06/24/2005
% modified by kaloyeh 06/24/2006
% modified by jhurwitz 06/22/2010 to remove references to eps

\documentclass[landscape]{slides}

\usepackage{graphicx}


\usepackage{standard-slide-include}

\title{Figures and   Tables in a {\LaTeX} Document}
\author{RSI {\number\year} Staff}
\date{}

\begin{document}

\begin{slide}
 \thispagestyle{empty}
 \maketitle
\end{slide}

\begin{slide}
  \begin{small}
    \tableofcontents
  \end{small}
\end{slide}

\addtocounter{slide}{-1}

\begin{slide}
  \slidetitle{The Table and Figure Environments}

  All tables go inside \texttt{table} environments; similarly, figures
  go in \texttt{figure} einvironments.  This environment should contain
  the table or figure and associated caption.

  \begin{verbatim}
    \begin{table}[htbp]
      ...  stuff here  ...
    \end{table}

    \begin{figure}[htbp]
      ...  stuff here  ...
    \end{figure}
  \end{verbatim}

  The \verb=[htbp]= controls where the table or figure is placed.

  Tables and figures do not need to go where you put them in the text.
  {\LaTeX} moves them around to prevent large areas of white space from
  appearing in your paper.
\end{slide}

\begin{slide}
  \slidetitle{Positioning Arguments}

  Each letter corresponds to a place where the table or figure should go:
  \begin{center}
  \begin{tabular}{lp{6in}}
    \texttt{b} (\texttt{\underline{B}ottom}) &  Place the table at the bottom of the
  current page. \\
    \texttt{h} (\texttt{\underline{H}ere}) &  Place the table at the spot where
      the table environment appears in the text \\
    \texttt{p} (\texttt{\underline{P}age}) &  Place the table at the top of the
  next page. \\
    \texttt{t} (\texttt{\underline{T}op}) &  Place the table at the top of the
  current page. \\
  \end{tabular}
  \end{center}

The first letter inside brackets has highest priority.  In the 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.
\end{slide}

\begin{slide}
  \slidetitle{Defining Tables}

  The table itself is defined by the \texttt{tabular} environment.  The syntax
  for this is:

  \begin{verbatim}
  \begin{table}[htbp]
    \begin{tabular}{column specification}
      ...  Table stuff in here  ...
    \end{tabular}
  \end{table}
  \end{verbatim}
\end{slide}

\begin{slide}
  \slidetitle{The Column Specification, Part 1}

  You need to tell {\LaTeX} how many columns your table will have and
  what kind of columns they will be.  The \texttt{column
  specification} has one letter per column.  For each column, there
  are three possibilities:
  \begin{center}
  \begin{tabular}{l@{\hspace{1in}}l}
    \texttt{c} & \underline{C}entered column \\
    \texttt{r} & \underline{R}ight-justified column \\
    \texttt{l} & \underline{L}eft-justified column
  \end{tabular}
  \end{center}
\end{slide}

\begin{slide}
  \slidetitle{The Column Specification, Part 2: Vertical Lines}

  If you want a vertical line between two columns, put a vertical line (\texttt{|}) in the column specification between the corresponding letters.

  A \texttt{|} appearing before any of the columns gives a line down
  the left edge of the table.

  A \texttt{|} appearing after all of the columns gives a line down
  the right edge of the table.
\end{slide}


\begin{slide}
  \slidetitle{Example Column Specifications}

  \begin{tabular}{l@{\hspace{1in}}p{5.75in}}
   Specification: & What It Does: \\
   \noalign{}\\
   \verb={ccc}= & Three columns, all centered, no vertical lines \\
   \\
   \verb={l|r}= & Two columns, one left-justified, one right-justified,
                  with a vertical line between them \\
   \\
   \verb={|l|l|l|l|l|}= & Five columns, all left-justified, with vertical lines
                          between each pair of columns and on right and left
\end{tabular}
\end{slide}

\begin{slide}
  \slidetitle{Separating Cells in a Row}

  Table cells in a row are separated with \texttt{\&}.  There should
  be no \texttt{\&} after the last cell in a row.  Example one-row
  table:
  \begin{verbatim}
  \begin{table}[htbp]
  \begin{tabular}{lrc}
    First Cell & Second Cell & Third Cell \\
  \end{tabular}
  \end{table}
  \end{verbatim}
\end{slide}

\begin{slide}
  \slidetitle{Ending Rows}

  Table rows are ended with \verb=\\=.  There should be a
  \verb=\\= at the end of each row.  Example two-row table:
  \begin{verbatim}
  \begin{table}[htbp]
  \begin{tabular}{lrc}
    Row 1, Cell 1 & Row 1, Cell 2 & Row 1, Cell 3 \\
    Row 2, Cell 1 & Row 2, Cell 2 & Row 2, Cell 3 \\
  \end{tabular}
  \end{table}
  \end{verbatim}
\end{slide}


\begin{slide}
  \slidetitle{Horizontal Lines Between Rows}

\cmd{hline} puts a horizontal line before or after a row.

\cmd{hline}\cmd{hline} puts two horizontal lines before or after a row.

Pop Quiz! Do you know what \cmd{hline}\cmd{hline}\cmd{hline} does?

\end{slide}


\begin{slide}  
  \slidetitle{Making a Table}
  \begin{verbatim}
 \begin{table}[htbp]
 \begin{tabular}{|l||c|c|} \hline\hline
   Ice Cream Store & Location & How to Get There \\ \hline
   Toscanini's & Central Square & Just walk! \\
   Herrell's & Harvard Square & Red Line \\
    J.P. Licks & Davis Square & Red Line \\
   Ben \& Jerry's & Newbury Street & Green Line \\ \hline\hline
 \end{tabular}
 \end{table} \end{verbatim}
  Gives us: \\ \\
  \begin{table}[htbp]
  \begin{tabular}{|l||c|c|} \hline\hline
   Ice Cream Store & Location & How to Get There \\ \hline
   Toscanini's & Central Square & Just walk! \\
   Herrell's & Harvard Square & Red Line \\
    J.P. Licks & Davis Square & Red Line \\
   Ben \& Jerry's & Newbury Street & Green Line \\ \hline\hline
  \end{tabular}
  \end{table}
\end{slide}

\begin{slide}
\slidetitle{Table of Tables}

\newbox\tabtabbox
\global\setbox\tabtabbox\hbox{$\vcenter{
\begin{verbatim}
\begin{tabular}{|c||c|c|} \hline
  %%%%%% Title row starts here
 & A & B \\ \hline\hline
  %%%%%% Row Foo starts here
  Foo & 
  \begin{tabular}{c} 1 \\ 2 \\ 3 \\ 4 \\
  \end{tabular} &
  \begin{tabular}{c} 2 \\ 5 \\ 9 \\ 8 \\
  \end{tabular} \\ \hline
  %%%%%% Row Bar starts here
  Bar & 
  \begin{tabular}{c} 1 \\ 2 \\ 3 \\ 4 \\
  \end{tabular} &
  \begin{tabular}{c} 31 \\ 23 \\ 16 \\ 42 \\
  \end{tabular} \\ \hline 
\end{tabular} 
\end{verbatim}
}$}

\begin{tabular}{ll}
  \begin{tabular}{|c||c|c|} \hline
    %%%%%% Title Row
    & A & B \\ \hline\hline
    %%%%%% Row Foo
    Foo & 
    \begin{tabular}{c}
	1 \\
	2 \\
	3 \\
	4 \\
    \end{tabular} &
    \begin{tabular}{c}
	2 \\
	5 \\
	9 \\
	8 \\
    \end{tabular} \\ \hline
  %%%%%% Row Bar
    Bar & 
    \begin{tabular}{c}
	1 \\
	2 \\
	3 \\
	4 \\
    \end{tabular} &
    \begin{tabular}{c}
	31 \\
	23 \\
	16 \\
	42 \\
    \end{tabular} \\ \hline
  \end{tabular}
& \box\tabtabbox
\end{tabular}
\end{slide}

\begin{slide}
\slidetitle{Graphics file formats}
Bitmap
\begin{itemize}
\item \texttt{.png} and \texttt{.tiff}: highest quality
\item \texttt{.jpeg}: good for photos, uses little space
\item \texttt{.gif}: good for line drawings, limited to 256 colors (NOT supported by \LaTeX)
\end{itemize}

Vector
\begin{itemize}
\item \texttt{.eps}: no longer supported by RSI \LaTeX
\item \texttt{.fig}: xfig graphics, good for editing
\end{itemize}
\end{slide}


\begin{slide}
\slidetitle{Viewing and editing graphics}
Bitmap
\begin{itemize}
\item \texttt{xv}: viewing
\item \texttt{gimp}: editing
\end{itemize}
Vector
\begin{itemize}
\item \texttt{gv}: viewing \texttt{.ps} files
\item \texttt{xfig}: editing \texttt{.fig} files
\end{itemize}
\end{slide}


\begin{slide}
  \slidetitle{Including a Graphic}

  To include a graphic in your document:
  \begin{verbatim}
  \begin{figure}[htbp]
    \includegraphics{filename}
  \end{figure}
  \end{verbatim}
\end{slide}

\begin{slide}
  \slidetitle{Example of an Included Graphic}

  \begin{verbatim}
   \begin{figure}[htbp]
     \includegraphics{house.pdf}
   \end{figure}
  \end{verbatim}
  Will give you:

   \begin{figure}[htbp]
     \includegraphics{house.eps}
   \end{figure}
\end{slide}

\begin{slide}
  \slidetitle{Scaling Graphics}

  Is your graphic too big? Does it ooze off into the right margin?

  \cmd{includegraphics} can take \texttt{scale} as an optional argument.
  \texttt{scale} is a number that the width and height of the figure will
  be multiplied by.

  Usage:  \cmd{includegraphics[scale=0.7]\{house.pdf\}}
\end{slide}

\begin{slide}
  \slidetitle{Scaling Example}

  \begin{verbatim}
   \begin{figure}[htbp]
     \includegraphics[scale=0.6]{house.pdf}
   \end{figure}
  \end{verbatim}
  Will give you:

  \begin{figure}[htbp]
    \includegraphics[scale=0.6]{house.eps}
  \end{figure}
\end{slide}

\begin{slide}
  \slidetitle{Setting Width and Height}

  Tired of trying to guess scale factors to get your figure to be just
  the right size?  Use the \texttt{height} or \texttt{width} optional
  argument to \cmd{includegraphics}.

  Usage:

  \cmd{includegraphics[height=2in]\{house.pdf\}} \\
            \cmd{includegraphics[width=6cm]\{house.pdf\}}

  A popular setting for \texttt{width} is \cmd{textwidth}.  This makes
  your figure be the exact width of the page.  Example:

  \verb|\includegraphics[width=\textwidth]{house.pdf}|
\end{slide}

\begin{slide}
  \slidetitle{Distortion}

  There is no need to set both the width and height---the dimension you
  do not specify will be scaled to keep the picture's proportions correct.  If
  you set both, you might get something like:
  \begin{verbatim}
   \begin{figure}[htbp]
     \includegraphics[height=1in,width=5in]{house.pdf}
   \end{figure}
  \end{verbatim}
  Which will give you:

  \begin{figure}[htbp]
    \includegraphics[height=1in,width=5in]{house.eps}
  \end{figure}
\end{slide}

\begin{slide}
  \slidetitle{Rotating Graphics}

  Your graphic looks like it lay down to take a nap.  Now what?  Use the
  \texttt{angle} optional argument.  The image will be rotated by a
  corresponding angle \emph{counterclockwise}.
%\end{slide}

%\begin{slide}
%\slidetitle{Rotating Example}
  \begin{verbatim}
   \begin{figure}[htbp]
     \includegraphics[angle=90]{house.pdf}
   \end{figure} \end{verbatim}
  Will give you:

  \begin{figure}[htbp]
    \includegraphics[angle=90]{house.eps}
  \end{figure}
\end{slide}

%% This one made no sense--rotation and scaling commute, right?
%% In any case it will confuse people, so I killed it.  -- cmihelic
%\begin{slide}
%  \slidetitle{Optional Argument Order}
%
%  The optional arguments for sizing and rotation are applied to the
%  figure in the order in which they are given.  Therefore, it usually
%  makes sense to specify the angle first, and then the size.
%
%\end{slide}


\begin{slide}
  \slidetitle{Centering Tables and Figures}

  To center a table or figure, put the \texttt{tabular} environment or
  \cmd{includegraphics} command respectively inside a \texttt{center}
  environment.  Examples:


\newbox\leftboxB
\newbox\rightboxB

\begingroup \overfullrule 0pt

\global\setbox\leftboxB\vbox{
	\hsize 0.47\hsize
\begin{verbatim}
\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{ccc}
      Tom & Dick & Harry \\
      Mary & Cathy & Anne \\
    \end{tabular}
  \end{center}
\end{table} \end{verbatim}
}

\global\setbox\rightboxB\vbox{
	\hsize 0.45\hsize
  \begin{verbatim}
  \begin{figure}[htbp]
    \begin{center}
      \includegraphics{house.pdf}
    \end{center}
  \end{figure}
  \end{verbatim}
}

\endgroup

  \begin{table}[htbp]
    \begin{tabular}{l|r}
	 \box\leftboxB & \box\rightboxB \\
    \end{tabular}
  \end{table}

\end{slide}

\begin{slide}
  \slidetitle{Captions}

  A figure or table without a caption feels lonely.  All figures and tables should have captions.  Use the \cmd{caption} command for this purpose.
  
  Example:
  \begin{verbatim}
  \begin{table}[htbp]
     \begin{center}
       \begin{tabular}{ccc}
         Tom & Dick & Harry \\
         Mary & Cathy & Anne \\
       \end{tabular}
     \end{center}
     \caption{Here are some names.}
   \end{table}
  \end{verbatim}
\end{slide}

\begin{slide}
  \slidetitle{Caption Example}
  \begin{verbatim}
    \begin{figure}[htbp]
      \begin{center}
        \includegraphics{house.pdf}
      \end{center}
      \caption{This is a pretty little house.}
    \end{figure} \end{verbatim}
    \begin{figure}[htbp]
     \begin{center}
       \includegraphics{house.eps}
     \end{center}
     \caption{This is a pretty little house.}
   \end{figure}
\end{slide}

%\begin{slide}
%  \slidetitle{Labeling Tables and Figures}
%
%  If you want to label a table or figure for later referencing, make sure to put the \cmd{label} command \emph{inside} the caption.  Otherwise it will not work.
%\end{slide}

\begin{slide}
  \slidetitle{Labeling Example}

  A labeled table would look somewhat like this:
  \begin{verbatim}
\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{c|c|c} \hline
       Tom & Dick & Harry \\ \hline
       Mary & Catherine & Anne \\ \hline
     \end{tabular}
  \end{center}
  \caption{This is a table of common names.}\label{tbl:names}
\end{table} \end{verbatim}
   and \verb=\ref{tbl:names}= would give the number of that table elsewhere.
\end{slide}


\begin{slide}
\slidetitle{Laying out graphics using tables}

\begin{verbatim}
\begin{table}[h]
\begin{tabular}{cc}
Piano player roll & Compact disc \\
\includegraphics[height=2.5in]{piano_player.pdf} &
\includegraphics[height=2.5in]{CD.pdf} \\
\end{tabular}
\end{table}
\end{verbatim}

\begin{table}[h]
\begin{tabular}{cc}
Piano player roll & Compact disc \\
\includegraphics[height=2.5in]{piano_player.eps} & \includegraphics[height=2.5in]{CD.eps} \\
\end{tabular}
\begin{center}
\tiny{Frankel F and Whitesides GM. (1997) {\it On the surface of things}.}
\end{center}
\end{table}
\end{slide}



\begin{slide}
\slidetitle{Laying out graphics using tables}
\begin{table}[h]
\begin{tabular}{|c|c|} \hline
Piano player roll & Compact disc \\ \hline
\includegraphics[height=2.5in]{piano_player.eps} & \includegraphics[height=2.5in]{CD.eps} \\ \hline
\end{tabular}
\begin{center}
\tiny{Frankel F and Whitesides GM. (1997) {\it On the surface of things}.}
\end{center}
\end{table}
\end{slide}


\begin{slide}
\slidetitle{Table of Figures!}
\begin{tabular}{ll}
\begin{tabular}{|c|c|} \hline
  \includegraphics[scale=0.7]{/mit/rsi/misc/images/cee.eps} &
  \includegraphics[scale=0.7]{/mit/rsi/misc/images/cee.eps} \\ 
  \small{CEE logo} & \small{CEE logo again} \\ \hline
  \includegraphics[scale=0.7]{/mit/rsi/misc/images/cee.eps} &
  \includegraphics[scale=0.7]{/mit/rsi/misc/images/cee.eps} \\ 
  \small{Third CEE logo} & \small{Last CEE logo} \\ \hline
\end{tabular}
&
\begin{tabular}{|c|l|} \hline
Time & Distorted House \\ \hline
1 s & \includegraphics[height=2cm, width=1in]{house.eps} \\
2 s & \includegraphics[height=2cm, width=1.5in]{house.eps} \\
3 s & \includegraphics[height=2cm, width=2in]{house.eps} \\
4 s & \includegraphics[height=2cm, width=2.5in]{house.eps} \\ \hline
\end{tabular}
\end{tabular}
\end{slide}



\begin{slide}
  \slidetitle{Common Table Errors}

  \begin{verbatim}
! Paragraph ended before \@array was complete.
<to be read again>
                   \par
l.11
     
? \end{verbatim}

This most likely means you forgot to end the column specification with
a \texttt{\}}.

In this case the error occurred in line 11.
\end{slide}

\begin{slide}
  \slidetitle{Common Table Errors}
  \begin{verbatim}
! LaTeX Error: Illegal character in array arg.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.7 \begin{tabular}{ccf}
                        
? \end{verbatim}

This means you used an invalid letter to designate a column time in the
column specification.  In the case shown, the culprit is the
``\texttt{f}'' following the two \texttt{c}'s

The error occurred in line 7 in this case.
\end{slide}

\begin{slide}
  \slidetitle{Common Table Errors}
  \begin{verbatim}
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 
                             
l.8 a & b & c &
                \\
? \end{verbatim}

This means that you have an extra \texttt{\&} in a row.  In the case
that generated the error, the table is defined to have three columns, so
there should be only two ampersands per row.

The extra \texttt{\&} could be caused by forgetting the \verb=\\= at the
end of a row.
\end{slide}

\begin{slide}
  \slidetitle*{Common Table Errors}
  \begin{small}
\begin{verbatim}
Runaway argument?
{The example table caption \end {table} \par This is the paragraph af\ETC.
! File ended while scanning use of \@xdblarg.
<inserted text> 
                \par 
<*> paper.tex 
             \nonstopmode\input
? \end{verbatim}
  \end{small}

  This means that you forgot to end a table caption with a \texttt{\}}.
  Notice that there is no line number listed.  If you get this error,
  you will have to check all your captions to make sure they are OK.
\end{slide}

\begin{slide}
  \slidetitle*{Common Table Errors}
\begin{small}
\begin{verbatim}
! Misplaced \noalign.
\hline ->\noalign 
                  {\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet...
l.9 d & e & f \hline
                    
? \end{verbatim}
\end{small}

This most likely means that you forgot the \verb=\\= following the last
row of the table and tried to put an \cmd{hline} following it to draw a
line below the table.

In this case the error is in line 9.
\end{slide}


\begin{slide}
  \slidetitle{Common Figure Errors}
  \begin{small}
  \begin{verbatim}
Runaway argument?
{This is a pretty picture \end {figure} \par This is the paragraph af\ETC.
! File ended while scanning use of \@xdblarg.
<inserted text> 
                \par 
<*> test.tex 
             \nonstopmode\input
? \end{verbatim}
\end{small}

  This means that you forgot to end a figure caption with a \texttt{\}}.
  Notice that there is no line number listed.  If you get this error,
  you will have to check all your captions to make sure they are OK.
\end{slide}

\end{document}


