# Conditional margins for printing [closed]

This is a follow up question to Different margins for on-screen pdf and for printed pdf.

I would like different margins for on-screen viewing and for paper. So, if someone views the pdf on a screen, they see centred text, but if they print it out, the margins have been adjusted to allow space for binding. See the images at the bottom for what I mean: The left one is for on-screen viewing and the right one is for paper (I've made the difference in margin sizes very large in order to make it more obvious).

Based on an answer to the aforementioned question by @EthanBolker, here's my MWE:

\documentclass[twoside,a4paper,12pt,openright]{book}

\ifdefined\screenview
\usepackage[bottom=3cm,top=3cm,outer=3.5cm,inner=3.5cm]{geometry} % Margins for on-screen viewing
\else
\usepackage[bottom=3cm,top=3cm,outer=1cm,inner=6cm]{geometry} % Margins for printing
\fi

\usepackage{lipsum}

\begin{document}

\lipsum

\end{document}


One then compiles this with the following command:

pdflatex "\def\screenview{} \input{filename.tex}"


Alas this doesn't work though: both the one-screen and printed versions are centred. It would seem that the geometry package doesn't work with conditionals like that. Any ideas?

## closed as off-topic by schtandard, Raaja, Phelype Oleinik, Sebastiano, MenschJul 24 at 16:25

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• doesn't this just select one of the options? Have you tried leaving out the option, and only using the command pdflatex \input{filename.tex}" I don't think this will do anything to accomplish your goal of having only one pdf which would change it´s own margins if it is printed or viewed on a computer. – Runar Jul 1 '16 at 13:59
• You may have misunderstood the answer you quoted. The idea is that pdflatex filename.tex will build the print version and pdflatex "\def\screenview{} \input{filename.tex}` will build the screen version. In the end you get two different PDFs optimized for two different purposes. – Willie Wong Jul 1 '16 at 14:33
• What you want to do is technically possible within the PDF specification. What you really need to do is to build the document in TWO layers with different margin off sets and make use of the OCG properties to set one as default visible and the other as default for print. I don't think there is a LaTeX package for automating this yet. One of the big problems being that if you change the various layout options, the screen and print versions need not have the same length! – Willie Wong Jul 1 '16 at 14:45
• ... which is obviously a problem if you are using the layers, since the page count of the document is fixed. I don't think PDF was/is designed with something similar to the CSS3 @media rule in mind. – Willie Wong Jul 1 '16 at 14:48
• I'm voting to close this question as off-topic because it was based on a misunderstanding. – schtandard Jul 24 at 15:01