# How to do pagenumbering in a fancy way

How do i get uneven increasing page numbers in the first half of my document, and in the second half in the second half?

Example: 1,3,5,7,8,6,4,2

Here are my thoughts on how to solve it:

My LaTeX document has n pages (n is always a multiple of 4), now i have to make a comparison of the counter page with n and depending on the resut print a different page number.

if page <= n/2 then printpagenumber(2*page-1)
else printpagenumber(2*n + 2 -2*page)


I have no knowledge of low level LaTeX manipuation but it is cear to me that the solution will involve some kind of counter arithmetic (with an conditional statement) together with redefining the command that actually prints the value of the page counter.

• Any particular reason you want to do this? Just if, for example, you are trying to organise signatures there are easier ways to do it! – cfr Jan 5 '14 at 23:40
• I am indeed afterwards creating a signatur/booklet with the pdfbook command. I want to have the pagenumbering of the booklet in this special way to be able to add more pages in the middle. With increasing odd numbers in the first half of the booklet and decreasing even in the second half you can make use of an index which will still give some information where to find a particular page. If you have other suggestions on how to make a booklet with index extendable i am interested to hear them. (The booklet is a Songbook with one song a page.) – Random Jan 5 '14 at 23:45

Here's a solution that uses the totalcount package to get the total number of pages (although other options are available), and renews \thepage command according to the scheme you described using a simple \if...\else...\fi construct; I have coloured the page numbers differently just for visual comparison, but presumably you'll have no need for this in your actual case.

The lipsum package is loaded purely for sample text- you'll probably want to remove it from your final document, together with the xcolor package.

% arara: pdflatex
\documentclass{article}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[page]{totalcount}

\renewcommand{\thepage}{%
\ifnum\value{page}<\numexpr\totalpages/2\relax
\color{red}\number\numexpr2*\value{page}-1\relax
\else
\color{blue}\number\numexpr2*\totalpages-2*\value{page}\relax
\fi
}
\begin{document}

Total pages: \totalpages

\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\end{document}

• Thank you very much! With this answer is was able to create a working solution. Since the totalcountpackage is not available at CTAN i used the similar totcount package instead. (The color package interferes with the index sorting so i removed it as you suggested.) – Random Jan 6 '14 at 3:42
• @Random totalcount.sty is part of the caption package. See here – karlkoeller Jan 6 '14 at 8:48