# Change theme mid-presentation using metropolis package

I am using beamer with metropolis theme. According to manual (page 6) metropolis offers option for background, namely dark and light, which can be set anytime, i.e. even mid-presentation, with the \metroset macro.

As expected, setting \metroset{background=dark} in preamble results in dark background and light normal text.

However, using \metroset{background=dark} in mid-document does not work as expected. The \metroset{background=dark} indeed sets the background of next slide to dark, but does not change the color of the normal text from dark to light. Hence, the text on dark background is invisible.

\documentclass{beamer}
\usetheme[progressbar=frametitle,block=fill]{metropolis}

\begin{document}
\begin{frame}{Light Theme}
Hello, world!
\end{frame}

\metroset{background=dark} % change background theme according to manual

\begin{frame}{Dark Theme}
Hello, world! % invisible
\end{frame}
\end{document}


The theme doesn't take sufficient account of the way Beamer's colours work. In particular, when you change the colour, the code uses \setbeamercolor but not \usebeamercolor, which is necessary for the change to take effect.

For example, the following works.

\documentclass{beamer}
\usetheme[progressbar=frametitle,block=fill]{metropolis}
\begin{document}
\begin{frame}{Light Theme}
Hello, world!
\end{frame}

\metroset{background=dark} % change background theme according to manual
\usebeamercolor[fg]{normal text}
\begin{frame}{Dark Theme}
Hello, world! % invisible
\end{frame}
\end{document}


Should you run into any weird spacing issues when using this theme, consider the possibility that it is introducing spurious spaces as the code suggests it may be quite keen to do so.

For things to work as expected, you could redefine the commands as follows.

\documentclass{beamer}
\usetheme[progressbar=frametitle,block=fill]{metropolis}
\makeatletter
\renewcommand{\metropolis@colors@dark}{%
\setbeamercolor{normal text}{%
fg=black!2,
bg=mDarkTeal
}%
\usebeamercolor[fg]{normal text}%
}
\renewcommand{\metropolis@colors@light}{%
\setbeamercolor{normal text}{%
fg=mDarkTeal,
bg=black!2
}%
\usebeamercolor[fg]{normal text}%
}
\makeatother
\begin{document}
\begin{frame}{Light Theme}
Hello, world!
\end{frame}
\metroset{background=dark} % change background theme according to manual
\begin{frame}{Dark Theme}
Hello, world! % invisible
\end{frame}
\metroset{background=light} % change background theme according to manual
\begin{frame}{Light Again}
Hello, world! % invisible
\end{frame}
\end{document}


• Great, now works as expected. Concerning ''weird spacing issues'' you have mentioned in the comment, do you imply that the source code of metropolis needs revision? – KlemenD Sep 14 '16 at 5:54
• Yes. There are uncommented line endings. I am not sure if these might create spaces in practice, but thought I'd mention it. (In the redefinitions above, I commented them for these particular commands.) – cfr Sep 14 '16 at 12:24