[Tex/LaTex] Don’t count empty pages in twoside+openright documents

double-sidedkoma-scriptpage-numbering

I'm working on a document that's a 300-page (scr)report, originally set up for one-sided printing. I'm currently preparing a second version of it that I want to be printed two-sided, naturally with the parts and chapters opening right. Its contents and layout are (and have to be) identical to the ›source‹ document except for the footer layout.

All this has been hassle-free, except for one thing: the blank pages that are inserted to make sure that parts and chapters start on recto pages only. Natively, TeX will count these pages as it does non-blank ones — but of course this throws off the correspondence between the two document's page numberings.

compare:

\documentclass[twoside=true,open=right,paper=A5]{scrreprt}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\Blinddocument
\Blinddocument
\end{document} 

and

\documentclass[twoside=false,open=any,paper=A5]{scrreprt}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\Blinddocument
\Blinddocument
\end{document} 

Is there an elegant way to take those empty pages out of the ›official‹ numbering (i.e. the one that's printed as opposed to TeX internal one)? Maybe by establishing two different sequences of page numbers? I can certainly think of a way to fiddle with the page counter whenever an implicit \cleardoublepage is invoked, but I guess that'll do more harm than good.

I do see the problem: what I want, effectively, is going to question the unambiguous correspondence between recto/verso and odd/even — which I'm sure TeX would prefer to preserve…

Best Answer

Keep track of how many blank pages you throw and adjust the print form of the page keeping the underlying counter with the actual side count.

\documentclass[twoside=true,open=right,paper=A5]{scrreprt}
\usepackage{blindtext}
\newcounter{blankpages}



\makeatletter

\def\cleardoubleoddstandardpage{%
\clearpage
\if@twoside \ifodd \c@page \else
 \stepcounter{blankpages}%
  \hbox {}\newpage \if@twocolumn \hbox {}\newpage \fi 
\fi \fi }
\makeatletter


\renewcommand\thepage{\the\numexpr\value{page}-\value{blankpages}\relax}
\begin{document}
\Blinddocument
\Blinddocument
\Blinddocument
\end{document}