How do I pass the document class options to a beamer theme?
I am writing a beamer theme. I would like to use the beamer class option aspectratio
to have individual layout settings for the 43
and 169
options. I tried to read the options with \DeclareOptionBeamer
and \ProcessOptionsBeamer
in my sty
file:
\ProvidesPackage{beamerthememytheme}[2020/03/10]
\newif\ifwidescreen
\widescreenfalse
\DeclareOptionBeamer{aspectratio}[43]{%
\ifnum#1=169 %
\widescreentrue%
\else\ifnum#1=43 %
\widescreenfalse%
\fi\fi
}
\ProcessOptionsBeamer
\mode<presentation>
The beamer class option aspectratio
is not passed to my theme:
\documentclass[aspectratio=169]{beamer}
\usetheme{mytheme}
\begin{document}
\begin{frame}
\ifwidescreen%
16:9
\else%
4:3
\fi
\end{frame}
\end{document}
However, it works as expected if I load the theme with the argument \usetheme[aspectratio=169]{mytheme}
. But I would like that the theme uses the same option as specified in the document class options if no option is provided.
beamer
themes can only inherit class options without=
.beamer
does this inside macro\beamer@filterclassoptions
. For example, in usage\documentclass[key1=val1, key2]{beamer}
, onlykey2
is passed to themes. So, do you want a general solution, or a specific way to detect the value passed toaspectratio
?aspectratio
option accepts different values : 1610, 169, 149, 141, 54, 43 and 32. Which values should set\ifwidescreen
to true?\ifwidesceen
to true.