# Compile print version and display version in 1 run

Often I have to create two documents with the same content but different layout: one version to print and another as a digital document. Therefore some small changes have to be made like other margins, page numbering, document settings from oneside --> twoside etc.

Up till now, I compile the document two times to get both the documents right. It would be much easier if I could just define two pagestyles (let's say print and display) and automatically run the compilation two times (one time with each pagestyle) so I get the two different pdf-files I need.

The code I use to define the layout for the printed document is:

\documentclass[10 pt, a4paper, twoside, openright]{book}
\usepackage{fancyhdr}
\usepackage{geometry}

\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}


The display version uses this layout settings:

\documentclass[10 pt, a4paper, oneside, openany]{book}
\usepackage{fancyhdr}
\usepackage{geometry}

\pagestyle{fancy}
\fancyhf{}
\fancyfoot[R]{\thepage}

• You cannot do that with LaTeX. But you can have a make file, or bat-file, that runs LaTeX multiple times with different flags. You would just have to push a button once. – Johannes_B May 15 '18 at 12:09
• @Johannes_B See my answer! – Keks Dose May 15 '18 at 16:28
• I think the closest concept is this one. But I don't get to make it work for my case... tex.stackexchange.com/questions/5228/… – Philippe May 15 '18 at 20:28
• @Keks Just as I said, no single run. – Johannes_B May 16 '18 at 0:12

## Use two different engines, pdfLaTeX and LuaLaTeX

Use two different engines, pdfLaTeX and LuaLaTeX, and the package ifluatex.

Untested code:

\documentclass...
all the packages you need for both variants.

\ifluatex
code for the digital version
\usepackage{fontenc}
\setmainfont...

\else
code for the printed version
\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}...

\fi
\begin{document}


So you just have to compile once, rename the PDF, change the engine, compile second time. Usually I even change the typeface between printed and digital version, because on screen some fonts are better to read than in the printed version.

Once in a while I even need three version, namely a simplified one for producing a html-document using tex4ht. The engine htlatex loads tex4ht and we can use that to make another fork:

\newif\ifhtlatex