Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can one make LaTeX print the pages numbering in reverse order, in the sense that if the document in question has N pages then the first page is numbered N, then N-1, ...?

share|improve this question
7  
Out of curiosity: why do you want to do this? –  Charles Stewart Nov 27 '10 at 10:58
6  
@Charles: I'd assume it's for an (boring) continuum mechanics textbook or similarly complex discipline, so that the students have an idea how many pages are there left for them to read.. –  Martin Tapankov Nov 29 '10 at 12:03
3  
@Martin: This sounds depressingly plausible. –  Charles Stewart Nov 29 '10 at 14:05
    
Too good question, I am that person who likes to have reverse page numbering, it is very motivating to read a book with this numbering. –  Kirk Hammett Sep 18 '11 at 18:51
add comment

4 Answers

up vote 5 down vote accepted

Here's an idea:

  1. Run the the *tex compilation as usual, and calculate the number of pages.
  2. On the second run, customize the page number to be shown as TotalPageNum-CurrentPagenum+1 (calculated by a formula, that is).
  3. There is no step 3.

You probably can skip doing this until your document is finished, so that this is a one-off operation.

There are so many things that might be unfeasible or outright difficult, but perhaps that could work. At least, this is not likely to be dependent on a particular document class.

share|improve this answer
    
Awesome solution –  Kirk Hammett Sep 18 '11 at 18:50
add comment

Here's a solution you can use for book class documents. It counts down the remaining pages from \mainmatter to the last page, ignoring pages in the \frontmatter division (mainly because I didn't want to overcomplicate things with roman numbering, but still wanted to provide an answer that recognised the issue). You'll obviously need to adjust this answer for non-book class documents (article, report, etc.; memoir and KOMA class documents are probably a whole new kettle of fish for which this solution is likely to prove unsuitable).

\documentclass[twoside]{book}
\usepackage{lastpage}
\usepackage{refcount}
\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{plain}
\let\oldmainmatter\mainmatter
\renewcommand\mainmatter{%
  \cleardoublepage%
  \oldmainmatter%
  \pagestyle{fancy}%
  \fancyhf{}%
  \renewcommand*\headrulewidth{0pt}%
  \fancyhead[LE,RO]{Page \thepage\ of \getpagerefnumber{LastPage}}%
  \fancyhead[LO,RE]{Remaining Pages \the\numexpr\getpagerefnumber{LastPage}-\thepage}%
}

\begin{document}
  \frontmatter
  \chapter{Front Matter}
  \lipsum[1-10]
  \mainmatter
  \chapter{Chapter One}
  \thispagestyle{empty}%
  \lipsum[1-15]
  \chapter{Chapter Two}
  \thispagestyle{empty}%
  \lipsum[1-10]
\end{document}
share|improve this answer
add comment

You have already received good answers for your questions, but I'd like to mention another way of getting around boring page numbering, or in general, boring display of any counter. I think that sometimes it is a better idea to display a counter visually. For example, consider this five page document:

enter image description here

The four counters on headers and footers visually display the current page number (for some styles, they also give an indication of remaining page numbers). This is inspired by the styles used in ConTeXt presentation modules and some beamer styles.

The above example is based on a ConTeXt module that I have written. It uses metapost to draw the counters (and only works with ConTeXt MkIV). For LaTeX, one can use the same idea and use tikz as a backend.

share|improve this answer
add comment

Using the answer of Geoffrey Jones (+1 for his answer), for different numbering schemes you could use (some of) this:

\documentclass[twoside]{book}
\usepackage{pageslts}
\usepackage{refcount}% only necessary if some page numbering scheme
                     % is used more than once
\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}
\makeatletter
\fancyhead[LE,RO]{Page "\thepage{}" (\theCurrentPageLocal{}) of %
 \lastpageref{pagesLTS.\pagesLTS@pnc} %
 (total \theCurrentPage{} of \lastpageref{LastPages})}%
\fancyhead[LO,RE]{Remaining Pages %
%  % If each page numbering scheme (roman, arabic,...) is used just once, 
%  % it is sufficient: 
%\@tempcnta=\value{pagesLTS.\pagesLTS@pnc.1.local.cnt}\relax%
%  % otherwise it is necessary: 
\@tempcnta=\getpagerefnumber{pagesLTS.\pagesLTS@pnc.local}\relax%
\advance\@tempcnta by -\theCurrentPageLocal%
\xdef\Remaining{\the\@tempcnta}%
\Remaining{} of \lastpageref{pagesLTS.\pagesLTS@pnc} %
(in total %
\@tempcnta=\value{pagesLTS.pagenr}\relax%
\advance\@tempcnta by -\theCurrentPage%
\xdef\Remaining{\the\@tempcnta}%
\Remaining%
)}
\makeatother

\begin{document}
\frontmatter
\chapter{Front Matter}
\lipsum[1-10]
\mainmatter
\chapter{Chapter One}
\thispagestyle{empty}%
\lipsum[1-15]
\chapter{Chapter Two}
\thispagestyle{empty}%
\lipsum[1-10]
\newpage
\pagenumbering{roman}
\lipsum[1-10]
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.