Tuesday, May 13, 2008

Managing the layout of figures in Latex

The placement of figures in your Latex document can sometimes be painful. I have recently started using the tabular environment to manage the layout of my figures in Latex documents. The idea is similar to using tables to manage layouts in html documents (before the popularity of CSS).

Here is an example:

Option 1:

\begin{figure}
\begin{center}
\begin{tabular}[c]{cc}
\begin{tabular}[c]{c}
%% Put figure (a) here
\end{tabular} &
\begin{tabular}[c]{c}
%% Put figure (b) here
\end{tabular} \\
(a) & (b) \\
\end{tabular}
\end{center}
\end{figure}


The above will result in a two-column layout for the sub-parts of a figure. An easier alternative is not to have the nesting in the tabular environment and just have the following.

Option 2:

\begin{figure}
\begin{center}
\begin{tabular}[c]{cc}
%% Put figure (a) here
&
%% Put figure (b) here \\
(a) & (b) \\
\end{tabular}
\end{center}
\end{figure}


When the sub-figures are of the about the same size, option 2 works great. But when the sub-figures have different sizes and you want to align the figures a particular way then using option 1 gives more control. The other advantage of using Option 1 is that you can take the nesting of the tabular environment as far as you like. Consider this variation on option 1:



\begin{figure}
\begin{center}
\begin{tabular}[c]{cc}
\begin{tabular}[c]{c}
%% Put figure (a)_0 here & Put figure (a)_1 here \\
\end{tabular} &
\begin{tabular}[c]{c}
%% Put figure (b) here
\end{tabular} \\
(a) & (b) \\
\end{tabular}
\end{center}
\end{figure}





In the above example we have added two figures in the first column
while we just have a one figure in the second column. Note that this
same result can be achieved using \multirow and \multicolumn within
one tabular environment. The explicit tabular environment is more
intuitive for me and makes it easier to visualize and design the
layout.

3 comments:

mrcalicut said...

Useful tips - thanks!

mrcalicut said...

Useful tips - thanks!

Ganesh

Unknown said...

My organization is discovering as the mother that regardless that babies don't incorporate manuals, Allow me to divide together with conquer! Every single day is containing joy, fear, laughter (loads of laughter), together with discouragement. And My organization is realizing the fact that my motherly intuition and common-sense are one of the best ways to look at my the baby, along by using a little recommendation; but only if I call for it. Just can follow mine advice, warring with my best baby has to be a great and cherished experience. babymanuals.net