1

I have a simple question in beamer: I have a slide with two columns, where each column contains some figures and some text. I want the figures to be centered within the columns but the text should be aligned to the left.

MWE:

\documentclass[8pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[OT1]{fontenc}
\usepackage[USenglish]{babel} 


\begin{document}

\begin{frame}{Title}
    \begin{columns}
    \begin{column}{0.5\textwidth}
    some short text
    \begin{figure}
    \includegraphics[width=.8\textwidth]{example-image-a}
    \end{figure}
    \begin{itemize}
    \item first item
    \item second item
    \item third item
    \end{itemize}
    \end{column}
    \begin{column}{0.5\textwidth}
    for $x<y$:
    \includegraphics[width=0.8\textwidth]{example-image-b}
    
    ... but for $x>y$:
    \includegraphics[width=0.8\textwidth]{example-image-c}
    \end{column}
    \end{columns}
    \end{frame}
\end{document}

As you can see I used the figures environment in the left column. This does center the image, as I want, but also adds some vertical whitespace above and below the image. Now in the right column I want the images to be centered, but without this additional whitespace. I have also tried the center environment, which also adds whitespace.

1
  • There is also \hfil\includegraphics{...}\newline or \par. Jul 14, 2020 at 13:35

2 Answers 2

2

Short answer: The trick is simply {\centering <you image> \par}.

Long answer: The trick is simply {\centering <you image> \par}. The \par could be changed by a blank line, but note that {\centering <you image>}\par will not work (compare in the MWE).

On the other hand, if there are not captions, instead of figure you can use a center environment to center and add some vertical space.

The MWE:

\documentclass{beamer}
\begin{document}
\begin{frame}{Title}
    \begin{columns}
    \begin{column}{0.5\textwidth}
    \dotfill\par% to see column width
    some short text
    \begin{center}
    \includegraphics[width=.1\textwidth]{example-image-a}
    \end{center}
    some short text
    \dotfill\par% to see column width

    \end{column}
    \begin{column}{0.5\textwidth}
    \dotfill\par% to see column width
    for $x<y$:\par
    {\centering\includegraphics[width=0.1\textwidth]{example-image-b}\par}
    ... but for $x>y$:\par
     {\centering\includegraphics[width=0.1\textwidth]{example-image-c}}\par %oooppp!!

    \dotfill\par% to see column width
    \end{column}
    \end{columns}
    \end{frame}
\end{document}
1

Your requirement is a bit confusing but maybe this is what you are looking for --the figure environ will center the image and the [T] option in columns will give the top alignment of the shorter column with respect to the longer column

enter image description here

\documentclass[8pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[OT1]{fontenc}
\usepackage[USenglish]{babel} 


\begin{document}

\begin{frame}{Title}
    \begin{columns}[T]
    \begin{column}{0.5\textwidth}
    some short text
    \begin{figure}
    \includegraphics[width=.8\textwidth]{example-image-a}
    \end{figure}
    \begin{itemize}
    \item first item
    \item second item
    \item third item
    \end{itemize}
    \end{column}
    \begin{column}{0.5\textwidth}
    for $x<y$:\begin{figure}
    \includegraphics[width=0.8\textwidth]{example-image-b}
    \end{figure}
    ... but for $x>y$:\begin{figure}
        \includegraphics[width=0.8\textwidth]{example-image-c}
    \end{figure}
    \end{column}
    \end{columns}
    \end{frame}
\end{document}

edit--to remove whitespace

with the help of\vspace you can adjust to your liking

    \begin{column}{0.5\textwidth}
    some short text\vspace{-6pt}
    \begin{figure}
    \includegraphics[width=.8\textwidth]{example-image-a}
    \end{figure}\vspace{-12pt}

enter image description here

1
  • Sorry for not being clear enough, but the problem is not vertical alignment. I only want the images horizontally centered. Your suggestion using the figures environment does this, but also adds some whitespace above and below the image, which I don't want in the right column.
    – CarlJacobi
    Jul 14, 2020 at 7:10

You must log in to answer this question.

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