2

I need to use separate page numbering in appendices while keeping the main numbering. I.e., when the page is in appendix, the header must be like "Appendix 1. Page X of XXX" where XXX is the number of pages in appendix. And in the footer the numbering must be uniform from the first page of the document to the end. How can I do it?

  • You need to create a new counter and increment it in the header or using the everypage package. You can print the last counter value using \ref{lastpage} (for example) and use \AtEndDocument{\addtocounter{mypage}{-1}\refstepcounter{mypage}\label{lastpage}} – John Kormylo Dec 23 '16 at 14:05
  • Please explain. I don't know TeX/LaTeX so good. – user121687 Dec 23 '16 at 15:15
  • I suppose you want me to create an MWE for you as well. Sigh! – John Kormylo Dec 23 '16 at 16:55
0

From your description I assume you are using oneside.

Note, since not every page has a header, I increment mypage using everypage, which runs after the page is complete but before the header is added. Also, \AtEndDocument runs before the last everypage.

\documentclass[oneside]{book}
\usepackage{lipsum}% MWE only
\usepackage{everypage}

\newcounter{mypage}
\AddEverypageHook{\stepcounter{mypage}}% before header
\AtEndDocument{\refstepcounter{mypage}\label{lastpage}\addtocounter{mypage}{-1}}

\makeatletter% create \pagestyle{appemdix}
\def\ps@appendix{%
    \def\@oddfoot{\hfil\thepage\hfil}%
    \let\@evenfoot=\@oddfoot
    \def\@oddhead{{\slshape\rightmark}\hfil Page \themypage{} of \ref{lastpage}}%
    \let\@evenhead=\@oddhead
    \let\@mkboth\markboth
}
\makeatother

\begin{document}
\chapter{Yada yada yada}
\lipsum[1-10]
\clearpage% push out last page before appendix
\appendix
\setcounter{mypage}{0}%
\pagestyle{appendix}%
\chapter{Test}
\lipsum[1-10]
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy