How to automatically create 4:3 AND 16:9 versions of my LaTeX Beamer slides?

As someone who often gives talks abroad, I usually do not know beforehand which resolutions the projector supports. Thus, I always create both a 4:3 and a 16:9 version of my slides, using e.g.

\documentclass[aspectratio=169]{beamer}


Is there a way to create both without having to change this line? I use pdflatex.

• since I use pandoc to generate latex anyway, personally I would just add a pandoc template variable in a custom template... and write a two-line bash file to run once pandoc -t latex -V aspectratio=169 and once pandoc -t latex -V aspectratio=43 but that's just me I gues... – mb21 Aug 11 '16 at 16:15

If the body of your talk is in talk.tex then you just need

talk43.tex

\documentclass[aspectratio=43]{beamer}\input{talk}


talk169.tex

\documentclass[aspectratio=169]{beamer}\input{talk}


then use a commandline of

pdflatex talk43;pdflatex talk169

• Does this mean you need two separate complete copies of the talk? – Aaron Hall Aug 11 '16 at 21:25
• @AaronHall no that's the whole point, you just need one copy, talk.tex – David Carlisle Aug 11 '16 at 21:34
• @DavidCarlisle: [Playing Devil's advocate] Why not add .tex to the input? It is never harmful :-) – Aditya Aug 11 '16 at 23:50
• @Aditya well a no one ever does it and it's a bad habit to do it unthinkingly as for example if you try it with \include it doesn't work at all. – David Carlisle Aug 11 '16 at 23:54
• @DavidCarlisle: Fair point. Should I submit a bugfix to correct \include :-) – Aditya Aug 12 '16 at 0:17

Referencing Two pdf versions from one single .TEX file?, you can use, for example:

\ifdefined\aspectRatio
\else
\def\aspectRatio{169}
\fi
\documentclass[aspectratio=\aspectRatio]{beamer}
\usepackage{lipsum}
\begin{document}
\begin{frame}
\lipsum[1]
\end{frame}
\end{document}


and then, assuming your file is beamer-test.tex run either of the following commands:

pdflatex beamer-test
pdflatex "\def\aspectRatio{43}\input{beamer-test.tex}"
pdflatex "\def\aspectRatio{169}\input{beamer-test.tex}"


You can automate the pdf naming convention by using arara, as I detailed in my answer to the post above.

• But you will get only one PDF, beamer-test.pdf, with the last aspect ratio defined. Unfortunately, setting \jobname to something different, eg using \aspectRatio has no effect. But one could rename beamer-test.pdf in between two pdflatex calls within a shell script. – AlexG Aug 12 '16 at 11:47
• @AlexG hence my link to my previous answer using arara :) run arara once, get two difference pdf files – cmhughes Aug 12 '16 at 12:46