3

My PDF document generated with LaTeX has roman numbering for the frontmatter.

My problem is: if I want to print a certain range of pages, it is very difficult to select them, because my PDF Viewer (Skim.app or Preview.app in MacOS X 10.6.8) seems to count the pages from the beginning of the PDF (1 = first page of PDF), but it displays the correct page numbers of the document (so page 1 is the first page of the mainmatter).

Is there a way to solve this so that the page numbers displayed are the same like those I have to enter in the printing dialog?

Here is a simple example:

\documentclass{scrbook}

\usepackage{hyperref}

\begin{document}

\frontmatter

\section{Here starts the Frontmatter}
text frontmatter

\mainmatter

\section{here starts the mainmatter}

text mainmatter: in my PDF viewer this is page 1, but when I would like to print it, I'd have to print page 3 (selecting page 1 in the print dialog would print page i, the first page of the PDF)

\backmatter

\section{here comes the backmatter}
text backmatter

\end{document}
  • It is possible (I'll look into it and post an answer), but it is certainly really tricky. – yo' Jan 03 '13 at 22:48
  • 2
    Does Adobe Reader have the correct page numbers? I'm pretty sure I've seen Reader take different numbering schemes into account. – Torbjørn T. Jan 03 '13 at 23:14
  • 1
    I do not know about Adobe Reader (can’t test here) but both Foxit and SumatraPDF show both numbers, the TeX number (i, ii, 1, 2, 3) and the PDF number (1, 2, 3, 4, 5). (In SumatraPDF you can even type “ii” to get to the second PDF page.) Though you still have to choose the PDF number to select the printing range. – Qrrbrbirlbel Jan 03 '13 at 23:30
  • @Qrrbrbirlbel + Torbjørn T.: thanks a lot! Your comment helped me finding the solution (see my answer: http://tex.stackexchange.com/a/89192/4009 ) – MostlyHarmless Jan 03 '13 at 23:31
  • 2
    @TorbjørnT. Acrobat shows the "text" page numbers and uses them in the print dialog as well, so never dare to have two pages with the same number (2 and ii is ok, but ii and ii is not). Another problem might be with a page that accidentally has no page number at all. – yo' Jan 03 '13 at 23:38
  • 1
    @tohecz: Seems like a serious bug in AR: The labels are just labels and every page can have the same or none. Viewers must cope with that. – Martin Schröder Jan 04 '13 at 10:35

2 Answers2

4

Thanks to the comments of Qrrbrbirlbel Torbjørn T. and I found the solution myself:

Skim.app (version 1.3.22) indeed displays both page numbers (example for first page of MWE):

enter image description here

  • it shows page "i" in the white box on the left
  • and it shows page "1 of 5" (the "real" page, starting by 1 for the first page) in the title bar of the window

Preview.app (version 5.0.1.) only displays the "real" page number (first page of PDF = 1) in the title bar

So in both applications if I choose the "real" page number from the title bar in the printing dialog, I can precisely select the page range to print.

2

Try to put this in your preamble. We use \EveryShipout to step our new counter xpage with every shipped page, then we use \texorpdfstring to write something different in text and in PDF comments. In the PDF comments we write this number. The modification of \pagenumbering ensures that our modified numbering is used correctly everywhere.

\makeatletter
\usepackage{everyshi}
\newcounter{xpage}\stepcounter{xpage}
\def\@xnumber#1#2{\texorpdfstring{#1{#2}}{\@arabic\c@xpage}}
\def\@xroman{\@xnumber{\@roman}} % repeat for every numbering style you use
\def\@xRoman{\@xnumber{\@Roman}} % repeat for every numbering style you use
\def\@xarabic{\@xnumber{\@arabic}} % repeat for every numbering style you use
\let\@xpagenumbering\pagenumbering
\def\pagenumbering#1{\@xpagenumbering{x#1}}
\pagenumbering{arabic}
\EveryShipout{\stepcounter{xpage}}
\makeatother
yo'
  • 51,322
  • thanks a lot for your help! Could your code have any side-effects on other things or features? I'm sorry, I found a simple solution to my printing problem myself (see my answer http://tex.stackexchange.com/a/89192/4009 ) – MostlyHarmless Jan 03 '13 at 23:32
  • 1
    @Martin It should work properly, I use a similar trick elsewhere myself: http://tex.stackexchange.com/questions/88398/how-to-make-page-numbering-with-ligature-roman-style – yo' Jan 03 '13 at 23:36
  • 1
    The count1to package defines a counter for the physical page number (and solves this problem for DVIs). – Martin Schröder Jan 04 '13 at 10:36