# How to insert a blank page depending on current page number?

I postprocess my PDF produced from my LaTeX-document through pdfbook and want to have the last page appear on the back cover. Thus, I need to have as many pages inserted before the last page so it gets onto a page number divisible by 4.

I looked to this question but

1. that seems complicated, and
2. I do not want to add additional packages if I can do without them.

Therefore my idea would be to add blank pages before the last page, until it becomes 3 modulo 4.

Pseudocode:

• regular document text
• if {current-page} % 4 != 3: \newpage
• if {current-page} % 4 != 3: \newpage
• if {current-page} % 4 != 3: \newpage
• content of last page

Is that feasible? How to code this in LaTeX?

• Your idea is rather curious. Why to you want to separate the last page from the rest of your text? Is it so self contained that this makes sense? Beside this: The question you linked too is the way to go, and if you don't like to load packages you shouldn't use latex but e.g. context. – Ulrike Fischer Aug 26 '13 at 8:11
• Yes, it is a sort of overview over the content. And when I reorder the pages for book-folding that last page becomes the back of a booklet. Thanks, for hinting that I need those packages for what I want to accomplish. I thought there might be an alternative approach I could follow more easily (I just to have to get better in latex, I suppose). – towi Aug 26 '13 at 8:15
• I think I didn't really understand your question: if you can put a \newpage before this pages then you can check the page number after it and add additional ~\newpage if necessary. – Ulrike Fischer Aug 26 '13 at 8:26
• Are you looking for a way to adapt egreg's answer in the linked post to your needs? – karlkoeller Aug 26 '13 at 8:33
• @karlkoeller I could adopt that solution, I suppose. I thought one might use something like \if{\getpagerefnumber{\thispage}\modulo4\equals3}{\clearpage} thrice and be done with it, no? – towi Aug 26 '13 at 9:08

Well the main problem is how to check for "modulo 4) and this is the core of egreg's answer in the other question. You only need to replace the reference to lastpage by the current page number. Attention this only works if there is really an explicit ' \newpage'!

\documentclass{article}
\makeatletter
\newcommand{\checkmultipleoffour}{%
\newpage %<---!
\count@=\the\c@page%<---
\@tempcnta=\count@
\divide\@tempcnta by 4
\multiply\@tempcnta by 4
\count@=\numexpr\count@-\@tempcnta\relax
\ifnum\count@>0
\pagestyle{empty}
\loop\ifnum\count@<4
\null\clearpage
\repeat
\fi
}

\makeatother
\begin{document}
blub

\checkmultipleoffour
blabla
\end{document}

• Why \count@=\the\c@page and not the simpler \count@=\c@page? – egreg Aug 26 '13 at 9:37
• I see... I think I get the idea behind that. the \null is the empty's page content, right? Can I emit \count@ on the "empty" page, for checking? value{\count@} did not do the trick, \the\count@ broke the calculation and only emits one page. {\the\count@} seemed to work, but I dont understand why -- or did it work by accident? – towi Aug 26 '13 at 9:57