4

I am trying to position three pictures together in a row. I am using beamer. The problem is that the pictures have a tendency to shift into the centre.

\begin{figure}
\includegraphics[height=3cm,width=3cm]{david.jpg}
\includegraphics[height=2cm,width=2cm]{stefan.jpg}

\includegraphics[height=2cm,width=2cm]{Hahn.jpg}
\end{figure}

How can I do this?

5
  • Perhaps \hfill in between the images? And no empty line, since this will act as a linebreak? If this does not help, can you please add a MWE instead of code fragments? Commented Aug 1, 2016 at 19:17
  • @samcarter what is MWE? Where shall I ou \hfill?
    – Al jabra
    Commented Aug 1, 2016 at 19:19
  • Between the graphics, like \includegraphics[height=3cm,width=3cm]{david.jpg}\hfill\includegraphics[height=2cm,width=2cm]{stefan.jpg} Commented Aug 1, 2016 at 19:22
  • Offtopic: I don't know what's the content of your images, but be careful, if you specify both the width and the height, the imageratio is most likely disturbed. Commented Aug 1, 2016 at 19:59

2 Answers 2

3

If you place an \hfill between the images, this will distribute them over the whole linewidth.

\documentclass{beamer}

\begin{document}

    \begin{frame}
        \begin{figure}
            \includegraphics[height=3cm,width=3cm]{example-image}
            \hfill
            \includegraphics[height=2cm,width=2cm]{example-image}
            \hfill
            \includegraphics[height=2cm,width=2cm]{example-image}
        \end{figure}
    \end{frame} 

\end{document}

enter image description here

2

You don't really need figure in beamer, since you presumably don't want your figures to float around. Here's an alternative.

\documentclass{beamer}

\begin{document}

    \begin{frame}\centering
            \begin{tabular}{cp{5mm}cp{5mm}c}
            \includegraphics[height=3cm,width=3cm]{example-image}
            &&
            \includegraphics[height=2cm,width=2cm]{example-image}
            &&
            \includegraphics[height=2cm,width=2cm]{example-image}
        \end{tabular}
    \end{frame} 

\end{document}

enter image description here

1
  • 1
    Beamer redefines the floating mechanism, so figures can safely be used, however they don't do much more than centring the content and add spacing. Commented Aug 2, 2016 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .