2

I am designing a beamer theme which shall be available in 16:9 and 4:3. To distinguish between the aspect ratio I came across Pass beamer class options to beamer theme and Query beamer document class option aspectratio in a .sty file for solutions in general, applying the second one for a simple print of the current aspect ratio:

\documentclass[aspectratio=169]{beamer}
\usepackage{filecontents}

\begin{filecontents}{beamerinnerthemeissue.sty}
\mode<presentation>
\defbeamertemplate*{title page}{texsx}[1][]
{
  \vskip5cm%
  \begin{beamercolorbox}[wd=12cm,leftskip=3cm,#1]{date}
    This presentation has the aspectratio=
    \makeatletter
    \ifdimcomp{\beamer@paperwidth}{=}{12.80cm}{43}{}
    \ifdimcomp{\beamer@paperwidth}{=}{14.85cm}{141}{}
    \ifdimcomp{\beamer@paperwidth}{=}{13.50cm}{32}{}
    \ifdimcomp{\beamer@paperwidth}{=}{12.50cm}{54}{}
    \ifdimcomp{\beamer@paperwidth}{=}{14.00cm}{149}{}
    \ifdimcomp{\beamer@paperwidth}{=}{16.00cm}
    {
      \ifdimcomp{\beamer@paperheight}{=}{10.00cm}{1610}{}
      \ifdimcomp{\beamer@paperheight}{=}{9.00cm}{169}{}
    }{}
    \makeatother
    \end{beamercolorbox}
  \vfill
}
\mode<all>
\end{filecontents}

\useinnertheme{issue}

\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}

However if one has to do this for multiple style elements (title page, part page, section page, ...), what is the neatest way of only making the comparison once and not in every single style element that is size dependent? I was thinking about storing the result in a simple \if43 and \if169 or a \is169or43{%16:9 code}{%4:3 code} and can then use those later.

But where should I place a check in the theme in general to check that either 16:9 or 4:3 was selected, because all other sizes won't work and then prepare the commands as above to be used by the rest of the them? Is there an element which for sure is parsed and applied directly after \begin{document}?

1 Answer 1

2

If 1) I interpreted the question correctly, and 2) I assume that beamer is not doing nasty things with the paper size after setting it in the very beginning, I would go for something like this:

\RequirePackage{filecontents}
\begin{filecontents}{beamerinnerthemeissue.sty}
\newif\if@ratio@wide \@ratio@widetrue
\ifdim\beamer@paperwidth=12.8cm
   \@ratio@widefalse
\else
    \beamer@paperwidth 16.00cm
    \beamer@paperheight 9.00cm
    \geometry{papersize={\beamer@paperwidth,\beamer@paperheight}}
\fi
\newcommand*{\foo}{This presentation has aspect ratio \if@ratio@wide16:9\else4:3\fi}
\end{filecontents}
    
\documentclass[aspectratio=169]{beamer}
\useinnertheme{issue}

\begin{document}
\begin{frame}
\foo
\end{frame}
\end{document}

As far as I see, beamer.cls sets the page size at the beginning. Passing beamer class options to themes seems to be indeed tricky, but luckily the page width for 4:3 is a unique value. Since you say that the aspect ratio must be either 4:3 or 16:9 I simply check whether the current page width is 12.8cm (the one corresponding to 4:3) and set a flag \if@ratio@wide to false. In any other case the flag is true and the aspect ratio is forced to 16:9 (even if you pass e.g. aspectratio=54). You can then use the familiar

\if@ratio@wide
    ...code for 16:9 ...
\else
   ... code for 4:3
\fi

to distinguish the cases in the rest of your code.

You must log in to answer this question.

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