When you open a PDF file made by TeX, you usually have some means of telling what the total page count is in the client GUI. I want to modify this page count such that the appendices is not counted along with the rest of the pages.
-
4The problem with this is that it depends on the viewer not on pdflatex. If you compare how different viewers display the page numbering when you have front matter with roman numbering before arabic numbering for the main matter, you'll see just how much is up to the viewer. Also you're effectively asking the viewer to lie to the user - which may make it less likely to be available as a feature - consider printing (the user should know how many pages they're paying for if they print the whole document)– Chris HApr 10, 2014 at 12:44
-
1related answer: tex.stackexchange.com/questions/57803/…– CharlesMarbleApr 10, 2014 at 13:29
1 Answer
You can only control, the page contents and show the number of pages there:
Example with zref-abspage
:
\documentclass{book}
\usepackage{zref-abspage}
\makeatletter
\AtBeginDocument{%
\newcommand*{\mainpages}{}%
\edef\mainpages{%
\zref@ifrefundefined{afterlastmain}{??}{%
\the\numexpr\zref@extractdefault{afterlastmain}{abspage}{1}-1\relax
}%
}%
\zref@refused{afterlastmain}%
}
\usepackage{etoolbox}
\pretocmd\appendix{%
\clearpage % or \cleardoublepage depending on counting an empty page
% before the appendix
\zref@labelbyprops{afterlastmain}{abspage}%
}{}{}
\makeatother
\begin{document}
This document has \mainpages{} pages without appendix pages.
\tableofcontents
\chapter{Introduction}
\chapter{Foobar}
\appendix
\chapter{First appendix}
\end{document}
Change \clearpage
to \cleardoublepage
if the empty page before the appendix should also be included into the count.
Do you mean with GUI the PDF viewer that might show the number of pages, e.g. the advanced document properties of AR:
then you get the absolute number of pages. Anything else would be a bug in the PDF viewer.
-
Not quite what I wanted but I can use this on the pages of the pdf itself I suppose.– AtheuzApr 11, 2014 at 8:54