[comp.text.tex] Side by side figures in LaTeX

scharein@cs.ubc.ca (Robert Scharein) (05/06/91)

Does anybody know of a way to place two figures (or tables) side by
side in a LaTeX document?  It seems that LaTeX puts the figures in 
a \parbox of width \textwidth so it would not seem possible without
changing \textwidth in the middle of the document. The LaTeX book 
recommends setting \textwidth only in the prologue. Any help would
be appreciated. 
                                           Thanks,
                                           Rob Scharein

hanche@imf.unit.no (Harald Hanche-Olsen) (05/06/91)

In article <1991May6.033627.24887@cs.ubc.ca> scharein@cs.ubc.ca (Robert Scharein) writes:

   Does anybody know of a way to place two figures (or tables) side by
   side in a LaTeX document?

Yes, anybody knows :-)  No, seriously, ...

   It seems that LaTeX puts the figures in 
   a \parbox of width \textwidth so it would not seem possible without
   changing \textwidth in the middle of the document.

I believe that the figure and table environments are very badly named.
THE figure ENVIRONMENT DOES NOT MAKE A FIGURE!  What it makes is a
float: A box that can be moved to wherever the output routine feels
like putting it (subject to certain constraints).  Similarly for the
table environment: The only diffence between the two (I believe) is
how the \caption command works.  You see, the \caption command within
the figure environment is what really defines the figure!  Now, there
is nothing to stop you from having two or more \caption's (or none!)
inside your figure environment.  If the environment had been named
"figures" instead, I believe fewer people would be confused.

So, the answer to your question is simple enough:  Put each of your
two figures including their \caption inside a \parbox, and set the two
boxes side by side inside the figure environment.  (The \parbox is so
the \caption command will know how wide it must be).  Warning:  I have
not tested this, and no doubt you will discover pitfalls.  But this is
at least in principle how I would do it.

- Harald Hanche-Olsen <hanche@imf.unit.no>
  Division of Mathematical Sciences
  The Norwegian Institute of Technology
  N-7034 Trondheim, NORWAY

anita@brahms.udel.edu (Anita Marie Hoover) (05/08/91)

In article <HANCHE.91May6155613@hufsa.imf.unit.no> hanche@imf.unit.no (Harald Hanche-Olsen) writes:
=>In article <1991May6.033627.24887@cs.ubc.ca> scharein@cs.ubc.ca (Robert Scharein) writes:
=>
=>   Does anybody know of a way to place two figures (or tables) side by
=>   side in a LaTeX document?
=>
=>Yes, anybody knows :-)  No, seriously, ...
=>
=>   It seems that LaTeX puts the figures in 
=>   a \parbox of width \textwidth so it would not seem possible without
=>   changing \textwidth in the middle of the document.
=>
=>I believe that the figure and table environments are very badly named.
=>THE figure ENVIRONMENT DOES NOT MAKE A FIGURE!  What it makes is a
=>float: A box that can be moved to wherever the output routine feels
=>like putting it (subject to certain constraints).  Similarly for the
=>table environment: The only diffence between the two (I believe) is
=>how the \caption command works.  You see, the \caption command within
=>the figure environment is what really defines the figure!  Now, there
=>is nothing to stop you from having two or more \caption's (or none!)
=>inside your figure environment.  If the environment had been named
=>"figures" instead, I believe fewer people would be confused.
=>
=>So, the answer to your question is simple enough:  Put each of your
=>two figures including their \caption inside a \parbox, and set the two
=>boxes side by side inside the figure environment.  (The \parbox is so
=>the \caption command will know how wide it must be).  Warning:  I have
=>not tested this, and no doubt you will discover pitfalls.  But this is
=>at least in principle how I would do it.
=>

Here is an example:

\documentstyle [12pt] {article}
\begin{document}
Here are two tables that are side by side.  This is especially nice
when wanting to compare costs, usage or other types of data.

\begin{table}[htbp]
\begin{center}
\begin{minipage}[t]{2.25in}
\caption{Usage Figures for Jan through Mar 1989}
\vspace*{.5\baselineskip}
\begin{center}
\begin{tabular}{|ccc|}\hline
Jan & Feb & Mar \\\hline
1 & 2 & 3\\\hline
\end{tabular}
\end{center}
\end{minipage}\hspace*{.375in}
\begin{minipage}[t]{2.25in}
\caption{Usage Figures for Apr through Jun 1989}
\vspace*{.5\baselineskip}
\begin{center}
\begin{tabular}{|ccc|}\hline
Apr & May & Jun \\\hline
4 & 5 & 6\\\hline
\end{tabular}
\end{center}
\end{minipage}
\end{center}
\end{table}

Now isn't this great!
\end{document}