GeneralProblem with Alphanumeric Page Numbering

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
hollett
Posts: 2
Joined: Mon Apr 21, 2008 4:46 pm

Problem with Alphanumeric Page Numbering

Post by hollett »

Hello all. I really need some help. Is there a way to get a string to print before each page number? For example:
D-1
D-2
D-3
In this example, "D-" preceeds each page number. Similar examples might be "Page - 1", "Page - 2", etc. I have searched many, many sites and am losing hope! :cry: Please help a newbie!

Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Problem with Alphanumeric Page Numbering

Post by gmedina »

You can redefine the \thepage command, as the following example suggestes:

Code: Select all

\documentclass{article}
\usepackage{lipsum}

\begin{document}

\renewcommand\thepage{D-\arabic{page}}
\lipsum[1-15]

\end{document}
The lipsum package was loaded only to automatically generate some text.

Perhaps the chappg package could be useful too.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
hollett
Posts: 2
Joined: Mon Apr 21, 2008 4:46 pm

Re: Problem with Alphanumeric Page Numbering

Post by hollett »

Thanks! That works perfectly! Also, if you want to change the string and numbering in each section, just repeat the renewcommand with the new string, adding setcounter to set the page counter back to 1 (or whatever you want it to be).

For Example:

\documentclass{article}
\usepackage{lipsum}

\begin{document}

\renewcommand\thepage{D-\arabic{page}}
\lipsum[1-15]

\newpage

\renewcommand\thepage{E-\arabic{page}}
\setcounter{page}{1}
\lipsum[1-15]

\end{document}

The result looks like this:
D-1
D-2
D-3
E-1
E-2
E-3
Post Reply