Horizontal alignment of subfigures

  • Tags :

When using subfloats (especially subfigures) in your documents, you probably noticed that two figures next to each other are aligned at the bottom of the figures. The result might be pretty disturbing as it will look chaotic. As always, there are a multiple ways to fix this. In this post, a very simple fix is presented! All we have to do is implement some minipage environments.

What you’ll be creating

In this post, I made use of a simple box that represents the figure. The box is an .eps file, which can be downloaded here.

The easy way

I should first say that I will not explain how to create subfigures. If you don’t know how this is done, try to google for it or take a look at the subfig documentation.

Set up your LaTeX documentclass as always (I picked the KOMA article class scrartcl). Next, we’ll need to use the following packages:

\usepackage{graphicx}		% handles figures
\usepackage{epstopdf}		% .eps to .pdf
\usepackage{subfig}		% handles subfloats

That’s that! Setting up the subfigure environment, where the figures are horizontally aligned at their centers is done as follows:

\begin{figure}
%% LARGER SUBFIGURE  
  \subfloat[Caption large box]{%
	\begin{minipage}[c][1\width]{%
	   0.5\textwidth}
	   \centering%	
	   \includegraphics[width=0.8\textwidth]{box}
	\end{minipage}}
%% SMALLER SUBFIGURE  	
  \subfloat[Captopn small box]{%
	\begin{minipage}[c][1\width]{%
	   0.5\textwidth}
	   \centering%
	   \includegraphics[width=0.4\textwidth]{box}
	\end{minipage}}
\caption{Caption of entire figure}
\end{figure}

Quite a big environment, isn’t it? However, if you take a look at what is really implemented it isn’t that hard at all! Besides the normal subfloat setup, the two boxes are wrapped in a minipage environment. That’s all :-)

The hard way

For those of you that don’t like the fix that is described above, this website provides another way. I personally find the fix presented above a lot more straight-forward.

Download

The .tex and .pdf file of what is described in this post can be downloaded as a zip-file.

2 Comments

  1. Frederik says:

    This works great for aligning their centers, but I can’t get this to work such that the tops of the figures are aligned. I thought changing those c’s after {minipage} to t’s would do the trick, but it did not.

    Any advice is appreciated, I’ve been searching and trying different things for far too long already!

Leave a Reply




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>