or
luki imported from SE
beamer
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.
Top Answer
samcarter
You don't need to access the documentclass option to know which aspect ratio is used.

If you just want to distinguish between 4:3 and all the other wider layouts, you could use a simplified version of https://topanswers.xyz/tex?q=805#a948 :

```
\ProvidesPackage{beamerthememytheme}[2020/03/10]

\newif\ifwidescreen
\ifdimcomp{\beamer@paperwidth}{=}{12.80cm}{}{\widescreentrue}
```
Answer #2
muzimuzhi Z imported from SE
Currently,

 - 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:
```tex
\RequirePackage{etoolbox}
\RequirePackage{scrlfile}
\makeatletter
\AfterPackage{beamerbaseoptions}{%
  % store full class options in \@classoptionslist@full
  \pretocmd{\beamer@filterclassoptions}
    {\let\@classoptionslist@full=\@classoptionslist}
    {}{\fail}%
}
\makeatother

\documentclass[aspectratio=169]{beamer}

\makeatletter
% extended \usetheme which inherits key=val class options
\newrobustcmd*\usethemeX[2][]{%
  \let\@classoptionslist=\@classoptionslist@full
  \usetheme[#1]{#2}%
  \let\@classoptionslist=\beamer@filteredclassoptionslist
}

% patch \ProcessOptionsBeamer
\patchcmd{\ProcessOptionsBeamer}
  {\@ifundefined{KV@\@currname @\CurrentOption}}
  {\expandafter\get@key\CurrentOption=\@nil
   \@ifundefined{KV@\@currname @\CurrentOption@key}}
  {}{\fail}
% helper macro
\def\get@key#1=#2\@nil{\def\CurrentOption@key{#1}}
\makeatother

\usethemeX{mytheme}

\begin{document}
\begin{frame}
  \ifwidescreen
    16:9
  \else
    4:3
  \fi
\end{frame}
\end{document}
```

By the way, the line containing `\if#1=43` in OP's example should be `\ifnum#1=43`.
Pass beamer class options to beamer theme

This is a dedicated room for discussion about this question.

Once logged in you can direct comments to the question poster (or any answer poster) here.