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:


    \ifnum#1=169 %
    \else\ifnum#1=43 %

The beamer class option aspectratio is not passed to my theme:






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.

  • I changed the title to make it a little clearer
    – daleif
    Mar 10, 2020 at 17:40
  • beamer themes can only inherit class options without =. beamer does this inside macro \beamer@filterclassoptions. For example, in usage \documentclass[key1=val1, key2]{beamer}, only key2 is passed to themes. So, do you want a general solution, or a specific way to detect the value passed to aspectratio? Mar 10, 2020 at 23:39
  • The aspectratio option accepts different values : 1610, 169, 149, 141, 54, 43 and 32. Which values should set \ifwidescreen to true? Mar 10, 2020 at 23:44
  • @PaulGaborit At the moment I am considering 169 and 43 only. So, 169 should set \ifwidesceen to true.
    – luki
    Mar 11, 2020 at 10:52

1 Answer 1



  • Usually, LaTeX classes store options in \@classoptionslist, and later loaded packages read this macro to inherit options from class.
  • However, beamer class stores key only options in \@classoptionslist (by using macro \beamer@filterclassoptions). This means, any class options containing =, e.g., aspectratio=<ratio>, is filtered out.
  • \ProcessOptionsBeamer seems to handle key only options, too. (I am not sure.)

The following example provides a workaround to overcome that:

  % store full class options in \@classoptionslist@full


% extended \usetheme which inherits key=val class options

% patch \ProcessOptionsBeamer
  {\@ifundefined{KV@\@currname @\CurrentOption}}
   \@ifundefined{KV@\@currname @\CurrentOption@key}}
% helper macro



By the way, the line containing \if#1=43 in OP's example should be \ifnum#1=43.

  • Wow, thanks for the workaround! This was more complicated than I expected.
    – luki
    Mar 11, 2020 at 10:50
  • @luki Hi, I have simplified the workaround, hope that helps. Mar 11, 2020 at 16:49
  • Great, thanks a lot!
    – luki
    Mar 15, 2020 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.