1.6.12

How to vertically center two images next to each other?


The baseline of images is at their bottom. You could change that by using \raisebox. For example:
\documentclass{article}
\usepackage[textwidth=6in]{geometry}
\usepackage[demo]{graphicx}
\begin{document}
\noindent
\begin{minipage}{6in}
  \centering
  \raisebox{-0.5\height}{\includegraphics[height=1.25in]{fig1.pdf}}
  \hspace*{.2in}
  \raisebox{-0.5\height}{\includegraphics[height=1in]{fig2.pdf}}
\end{minipage}
\end{document}
Gives vertically centered images, here black rectangles because of the demo option:
alt text
Raising their baseline by .5\height has the nice effect that also following text would be aligned at the new baseline at the vertical center.
Alternatively, you could use \vcenter, which is working fine as well:
\begin{minipage}{6in}
  \centering
  $\vcenter{\hbox{\includegraphics[height=2.25in]{fig1.pdf}}}$
  \hspace*{.2in}
  $\vcenter{\hbox{\includegraphics[height=1in]{fig2.pdf}}}$
  following text\end{minipage}

No hay comentarios:

Publicar un comentario