The following code typesets a 12 page document; text only appears on every other page and there's an empty page between two text pages:
\documentclass{article}
\usepackage{atbegshi}
\usepackage{lipsum}
\makeatletter
\AtBeginShipout{%
\ifodd\c@page
\begingroup
\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox
\global\AtBegShi@Discardedtrue
\mbox{}\thispagestyle{empty}\clearpage
\endgroup
\else
\fi%
}
\makeatother
\begin{document}
\lipsum[1-30]
\end{document}
Now I am trying to number sequentially the pages with text in them; with the code above pages with text are numbered 1,3,5,... but I would like them to be 1,2,3,... I did some attempts but none of them produced the desired result. How can I achieve the consecutive numbering?
The idea is to wrap this into a command that will allow to change the behaviour of the text flow inside a group: when invoked, the command will cause the text to be typeset in every other page but maintaining the consecutive numbering for the pages with text; once the group ends the text and numbering must return to their normal behaviour.
\shipout
inside\AtBeginShipout
. An empty page can output by\AtBeginShipoutOriginalShipout\null
(absolute page counters have to be corrected manually).\clearpage
might even add further float pages.\label
based approaches like\checkoddpage
are not needed.\shipout
inside\AtBeginShipout
? Why don't you recommend doing so?\clearpage
. Thus it can happen that in the middle of shipping out a page material is added somewhere later and the output routine is called again and might want to ship out a page while shipping out a previous page. A mess already.atbegshi
is not reentrant, one of the reasons are possible global assignments of the shipout box.