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.

2
  • 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
    Commented Apr 10, 2014 at 12:44
  • 1
    related answer: tex.stackexchange.com/questions/57803/… Commented Apr 10, 2014 at 13:29

1 Answer 1

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.

1
  • Not quite what I wanted but I can use this on the pages of the pdf itself I suppose.
    – Atheuz
    Commented Apr 11, 2014 at 8:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .