# Create two documents with different page sizes

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?

• You can change the page size using geometry, but the \if@twoside flag should be set using the document class. – John Kormylo Nov 29 '18 at 15:22
• So I can do it only once and there’s no way to use one .tex file to generate two documents without manually changing that between renders? – Althorion Nov 29 '18 at 15:26
• It is one pdf per run anyway. TeX was written back when RAM was expensive. – John Kormylo Nov 29 '18 at 15:37
• Sure. I hoped things have changed with XeTeX (or maybe LuaTeX), but if not, it’s not that big of a deal. Thanks. – Althorion Nov 29 '18 at 15:42

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.

# Passing arguments to a single file

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


# Using latexmk with multiple files

You 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:

1. a4.tex
\documentclass[paper=A4, oneside, fontsize=16pt, DIV=calc]{scrbook}

\input{text}

1. b5.tex
\documentclass[paper=B5, twoside, fontsize=10pt, DIV=calc]{scrbook}

\input{text}

1. text.tex
\begin{document}
Text
\end{document}

1. latexmkrc (tells latexmk which files to compile)
@default_files = ('a4.tex', 'b5.tex');


# pgfpages package

If 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.