1

I am using the Metropolis theme in beamer, and wondering why having \includegraphics within braces {...} doesn't work (image doesn't get added in). I get a blank slide (with title) with the code below:

\documentclass[10pt]{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\begin{document}
\begin{frame}{test}
{\hfill\includegraphics[width=1cm]{example-image}\hfill}
\end{frame}
\end{document}

Commenting out the metropolis line, (thus, switching to using the default beamer theme), the image appears as expected. So I know this behaviour has something to do with the metropolis theme.

I know I can remove the braces, but you can imagine a scenario where I want some effect localized/grouped, e.g. \color{blue}. I want to know why does this happen?

4
  • 1
    If you leave an empty line after \begin{frame}{test} the image shows up. I prefer the cleaner syntax \begin{frame} \frametitle{test} {\hfill\includegraphics[width=1cm]{example-image}\hfill} \end{frame}, with which the problem is absent.
    – user121799
    Feb 6, 2019 at 0:23
  • @marmot does this mean \begin{frame} takes a second argument? do you know what this second argument means/refers to?
    – ksgj1
    Feb 6, 2019 at 0:26
  • Right, but the default beamer theme doesn't have this issue, so I'm wondering what's the difference introduced by metropolis here.
    – ksgj1
    Feb 6, 2019 at 0:27
  • I agree that one may suspect this but I do not know for sure whether this is the case, simply since I always use \frametitle because of problems I had with the other syntax.
    – user121799
    Feb 6, 2019 at 0:28

1 Answer 1

2

It's not a problem with beamer-metropolis, it's a problem with your code.

beamerdefines this syntax \begin{frame}{frame title}{frame subtitle} where title and subtitle are optionals. Therefore your figure is considered as a subtitle, but metropolis has no subtitle commands, then it's ignored.

Compare this

\documentclass[10pt]{beamer}
\begin{document}
\begin{frame}{test}
{\hfill\includegraphics[width=1cm]{example-image}\hfill}
\end{frame}
\end{document}

enter image description here

with this:

\documentclass[10pt]{beamer}
\begin{document}
\begin{frame}{test}

{\hfill\includegraphics[width=1cm]{example-image}\hfill}
\end{frame}
\end{document}

enter image description here

As you can see, even without metropolis your syntax does not produce the expected result.

If you don't want to leave an empty line between title and contents, use this alternative syntax (or at least don't start new line with '{')

\documentclass[10pt]{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\begin{document}
\begin{frame}{test}
\centerline{\includegraphics[width=1cm]{example-image}}
%{\hfill\includegraphics[width=1cm]{example-image}\hfill}
\end{frame}
\end{document}

enter image description here

1
  • i would mentioned that for titles and subtitles is better to use \frametitle{...} and \framesubtitle{...} (as recommended in beamer documentation). using them the op error will not happen.
    – Zarko
    Feb 8, 2019 at 13:22

You must log in to answer this question.

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