I need to create two versions of a pdf rendered from my .tex file, one in A4 one-side format, and one in B5 two-side format.
I do this by changing the class options (I use memoir, if that matters) and re-rendering the file. Is there any better way?
I often create booklets in standard and large-print formats in different sizes from a single source. There are a few approaches.
If there is certain content that needs to be included or excluded from different formats, you could use something like the comment
or multiaudience
packages.
If you want a single file from which to generate multiple formats, you could use something like this text.tex
, with optional setup for arara
:
% arara: lualatex
% arara: lualatex: { options: ['--jobname=text-largeprint', '\def\largeprint{}\input{text}'] }
\documentclass{scrbook}
\ifdefined\largeprint
\KOMAoptions{paper=A4, oneside, fontsize=16pt, DIV=calc}
\else
\KOMAoptions{paper=B5, twoside, fontsize=10pt, DIV=calc}
\fi
\begin{document}
Text
\end{document}
The B5 version would run normally with lualatex text.tex
. To produce the A4 version in a separate file called text-largeprint.pdf
:
$ lualatex --jobname=text-largeprint "\def\largeprint{}\input{text}"
If you include the comments at the beginning of the file, you can then run both commands at once:
$ arara text.tex
latexmk
with multiple filesYou could also create two files with the options you want and another with the source text, then run latexmk
to generate both versions at once. This is one way to organize the files:
a4.tex
\documentclass[paper=A4, oneside, fontsize=16pt, DIV=calc]{scrbook}
\input{text}
b5.tex
\documentclass[paper=B5, twoside, fontsize=10pt, DIV=calc]{scrbook}
\input{text}
text.tex
\begin{document}
Text
\end{document}
latexmkrc
(tells latexmk
which files to compile)@default_files = ('a4.tex', 'b5.tex');
pgfpages
packageIf the pagination needs to be the same, it's much easier to resize the PDF to another size, although the design might look a bit off: this has already been covered in Large-print version of exam.
\if@twoside
flag should be set using the document class.