1

I have several frames containing figures of the same size but captions of different length. The code I'm currently using is something like this:

\begin{frame}
    \begin{figure}[!ht]
        \centering
        \includegraphics[width=0.7\textwidth]{image1}
        \caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
    \end{figure}    
\end{frame}

\begin{frame}
    \begin{figure}[!ht]
        \centering
        \includegraphics[width=0.7\textwidth]{image2}    
        \caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxx}
    \end{figure}
\end{frame}

The result is that the two figures are not in the same location inside their respective frames: the first one has a wider top margin than the second one.

How can I align those figures at top so that they will occupy the same space in each frame?

1

Adding a \ vfill` seems to do the trick:

\documentclass[demo]{beamer}
\usepackage{caption}

\begin{document}

\begin{frame}
  \begin{figure}[!ht]
        \centering
        \includegraphics[width=0.7\textwidth]{image1}
   \caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
 \end{figure}
\vfill\null
\end{frame}

\begin{frame}
 \begin{figure}[!ht]
        \centering
        \includegraphics[width=0.7\textwidth]{image2}
        \caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxx}
 \end{figure}
\end{frame}

\end{document} 

enter image description here

  • Hi, thanks for the answer. I can see how it should work but in my case the problem is still there. It seems that \vfill doesn't work. How can this be? – PrinceOfBorgo Jul 18 at 17:32
  • Did you add \null (or \mbox{}) afterwards? – Bernard Jul 18 at 17:35
  • Yes, I added \vfill\null – PrinceOfBorgo Jul 18 at 17:36
  • Just in case:leavevmode just before vfill. If it isn't enough, you should post a minimal example reproducing the problem. Oh! b.t.w., do you also have the problem with just my code? – Bernard Jul 18 at 17:39
  • Using demo option it works but removing that it doesn't neither with \leavevmode. I tried to replace \null with a and in each frame it appears at different distance from bottom as if the height of each frame is not always the same. – PrinceOfBorgo Jul 18 at 17:46
1

Depending on the exact output you want to achieve, you could also add the [t] option to the frame environments:

enter image description here

\documentclass[demo]{beamer}
\usepackage{caption}

\begin{document}

\begin{frame}[t]
  \begin{figure}
        \centering
        \includegraphics[width=0.7\textwidth]{image1}
   \caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
 \end{figure}

\end{frame}

\begin{frame}[t]
 \begin{figure}
        \centering
        \includegraphics[width=0.7\textwidth]{image2}
        \caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                 xxxxxxxxxxxxxxxxxxx}
 \end{figure}
\end{frame}

\end{document} 

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.