0

I am trying to create my own beamer theme that should be loaded with beamer's compress option by default. I tried using the following declaration, which I saw on a few different answers and themes:

\DeclareOptionBeamer{compress}{\beamer@compresstrue}
\ProcessOptionsBeamer

but the following MWE produces the non-compressed version of the navigation bar, with each subsection creating its own line of dots:

nocompress

\begin{filecontents}{beamerthemeCompress.sty}
   \DeclareOptionBeamer{compress}{\beamer@compresstrue}
   \ProcessOptionsBeamer

    \setbeamertemplate{headline}{%
      \begin{beamercolorbox}[ht=2.25ex,dp=3.25ex]{section in head/foot}
        \tiny\insertnavigation{.2\paperwidth}
      \end{beamercolorbox}%
    }
\end{filecontents}

\documentclass{beamer}
\usetheme{Compress}

\begin{document}

\section{Intro}
\subsection{Intro Sub1}
\begin{frame}{Frame 1}
    Some Text
\end{frame}
\subsection{Intro Sub2}
\begin{frame}{Frame 2}
    Some Text
\end{frame}

\section{Cont}
\subsection{Cont Sub1}
\begin{frame}{Frame 3}
    Some Text
\end{frame}
\subsection{Cont Sub2}
\begin{frame}{Frame 4}
    Some Text
\end{frame}
\end{document}

Only when I use \documentclass[compress]{beamer} I get the desired compressed version, with all dots on the same line:

yescompress

How can I make my theme always look like this without having to load the class with [compress]?

1 Answer 1

2

When you \DeclareOptionBeamer you just redefine the definition, not execute it. When you then \ProcessOptionsBeamer you just execute the options given, not every defined option.

Hence your code effectively does nothing and if you dropped it completely you'd just get the same because the beamer class already handles your compress option.

Instead, simply execute the option's code as if it was given and you'll get the results you want:

\begin{filecontents}{beamerthemeCompress.sty}
   \beamer@compresstrue

    \setbeamertemplate{headline}{%
      \begin{beamercolorbox}[ht=2.25ex,dp=3.25ex]{section in head/foot}
        \tiny\insertnavigation{.2\paperwidth}
      \end{beamercolorbox}%
    }
\end{filecontents}

\documentclass{beamer}
\usetheme{Compress}

\begin{document}

\section{Intro}
\subsection{Intro Sub1}
\begin{frame}{Frame 1}
    Some Text
\end{frame}
\subsection{Intro Sub2}
\begin{frame}{Frame 2}
    Some Text
\end{frame}

\section{Cont}
\subsection{Cont Sub1}
\begin{frame}{Frame 3}
    Some Text
\end{frame}
\subsection{Cont Sub2}
\begin{frame}{Frame 4}
    Some Text
\end{frame}
\end{document}

You must log in to answer this question.

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