15

I would like to make my figures with bottom-aligned, but the arrows are still in the center. Here is my code:

\begin{figure}[!ht]
\centering
\begin{minipage}[c]{0.2\textwidth}
  \includegraphics[width=1\textwidth]{dicore1.eps}
\end{minipage}
$\rightarrow$
\begin{minipage}[c]{0.2\textwidth}
 \centering
 \includegraphics[width=1\textwidth]{dicore2.eps}
\end{minipage}
$\rightarrow$
\begin{minipage}[c]{0.2\textwidth}
 \centering
\includegraphics[width=0.8\textwidth]{dicore3.eps}
\end{minipage}
$\rightarrow$
\begin{minipage}[b]{0.2\textwidth}
 \centering
\includegraphics[width=0.6\textwidth]{dicore4.eps}
\end{minipage}
\caption{A series of retractions.}
\label{fig:Retr}
\end{figure}

It strangely looked like this: enter image description here

If I make all of them to be \begin{minipage}[b], then they are indeed bottom-aligned, but the arrows are also bottom aligned.

How could I solve it?

28

Another option is to change the definition of the last minipage to

\begin{minipage}[t][][b]{0.2\textwidth}

The first optional argument, t, defines the 'anchor' of the minipage, so here the top is placed on the baseline. The last optional argument, b, defines where in the minipage the content should be placed, here it is placed at the bottom.

The second optional argument, which I left empty, defines the height of the minipage. I'm not exactly sure what happens when it is left empty, I assumed it would use the natural height, but someone else would have to verify that.

4

I've stripped your use of minipages to isolate a rudimentary (yet effective) way of dealing with the problem of alignment:

enter image description here

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\begin{document}
\begin{figure}[!ht]
  \centering
  \setbox1=\hbox{\includegraphics[width=.2\linewidth]{example-image-a}}% Largest image
  \includegraphics[width=.2\linewidth]{example-image-a}
  \raisebox{\dimexpr.5\ht1-.5\height}{$\rightarrow$}
  \includegraphics[width=.2\linewidth]{example-image-b}
  \raisebox{\dimexpr.5\ht1-.5\height}{$\rightarrow$}
  \includegraphics[width=.2\linewidth]{example-image-c}
  \raisebox{\dimexpr.5\ht1-.5\height}{$\rightarrow$}
  \raisebox{\dimexpr.5\ht1-.5\height}{\includegraphics[width=.1\linewidth]{example-image-a}}
  \caption{A series of retractions.}
  \label{fig:Retr}
\end{figure}
\end{document}

In your instance, you would only need to raise the arrows using \raisebox{\dimexpr.5\ht1-.5\height}{$\rightarrow$}, although I've done it for the last disproportionate image as well.

The idea is to store in a box the largest of the objects. I did so in \box1. Then, subsequent stuff aligned with the baseline is raise by \dimexpr.5\ht1-.5\height (or 50% of the height of the largest object minus 50% of their own height), centering them vertically.


Another option is to use adjustbox:

enter image description here

\documentclass{article}
\usepackage[export]{adjustbox}% http://ctan.org/pkg/adjustbox
\begin{document}
\begin{figure}[!ht]
  \centering
  \includegraphics[valign=c,width=.2\linewidth]{example-image-a}
  $\rightarrow$
  \includegraphics[valign=c,width=.2\linewidth]{example-image-b}
  $\rightarrow$
  \includegraphics[valign=c,width=.2\linewidth]{example-image-c}
  $\rightarrow$
  \includegraphics[valign=t,width=.1\linewidth]{example-image-a}
  \caption{A series of retractions.}
  \label{fig:Retr}
\end{figure}
\end{document}

The export option ports the keys from adjustbox to that of graphicx so you can valign your images. Note that the valign option sets the vertical anchor to which other content aligns. So, as you can see, I've set valign=t for the last image, meaning the top of that image will align with the anchors of the other components in the horizontal list - center.

  • sorry, seems I did not get it! – Ginger Sep 7 '13 at 18:37
  • I changed all [c] to [b] and replace $\rightarrow$ to\raisebox{\dimexpr.5\ht1-.5\height}{$\rightarrow$}, but it does not work! – Ginger Sep 7 '13 at 18:39
  • @Ginger: Did you store the largest image in \box1 like I did with \setbox? Also, you should try it without the minipages like I did - the width specification of \includegraphics should be sufficient. – Werner Sep 7 '13 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.