5

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.

Atheuz
  • 63
  • 4
    The 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 H Apr 10 '14 at 12:44
  • 1
    related answer: http://tex.stackexchange.com/questions/57803/stop-page-count-before-appendix?rq=1 – CharlesMarble Apr 10 '14 at 13:29

1 Answers1

4

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}

Result

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:

Advanced document properties

then you get the absolute number of pages. Anything else would be a bug in the PDF viewer.

Heiko Oberdiek
  • 271,626