I am writing an important document which has ended up being 13 pages.

For superstitious reasons, I want the page number on the last page to show up as "12+1". In other words, I want the page numbers to be: 1, 2, …, 11, 12, 12+1.

How do I do this?

  • 1
    Welcome to TeX.SX! Please help us help you by providing a minimal compilable code example (MWE). – TeXnician Sep 11 at 10:10
  • 10
    But you wrote »13« here yourself! Beware! – Keks Dose Sep 11 at 13:27
  • 13
    And the question is currently at 13 upvotes, I like to imagine this isn't a coincidence. – LiefdeWen Sep 11 at 13:38
  • 1
    @jfbu Update from a multi-stack user: This is on the HNQ. – FoxElemental Sep 12 at 21:14
  • (salvaged from comment). This is a duplicate of tex.stackexchange.com/questions/87617/how-to-suppress-page-13 – jfbu Sep 13 at 15:36
up vote 50 down vote accepted

Define a new counter format:

\documentclass{article}

\usepackage{kantlipsum} % for mock text

\makeatletter
\newcommand{\fixedarabic}[1]{%
  \expandafter\@fixedarabic\csname c@#1\endcsname
}
\newcommand{\@fixedarabic}[1]{%
  \ifnum#1=13 12${}+{}$1\else\number#1\fi
}
\makeatother

\pagenumbering{fixedarabic}

\begin{document}

\kant[1-50]

\end{document}

enter image description here

  • 21
    12+1 is much to obvious. I suggest $\sum_{i=1}^5 i -3$. – Ulrike Fischer Sep 11 at 10:18
  • 2
    For my own understanding, could you comment on the differences between defining a new counter format and only redefining \thepage as follows: \renewcommand{\thepage}{\ifnum13=\value{page}12+1\else\the\value{page}\fi}? (The latter also works.) – Max Sep 11 at 10:25
  • 1
    @Max More general. – egreg Sep 11 at 10:28
  • 6
    Many thanks! This worked. It was my first time posting a question here and I am amazed how quickly help came. Thank you all! – Amir Ali Ahmadi Sep 11 at 10:49
  • 1
    @NieDzejkob No, to 12, which is different from 13 anyhow. ;-) – egreg Sep 11 at 14:50

It could be a complex solution to convert the counter page to "12+1" if the value reach 13, but if only matter when 13 is the last page, why not simply change the footer just before \end{document} to "12+1"?.

\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
aaa 
\setcounter{page}{12} % this is the 12th page
\newpage
bbb
\cfoot{12+1} % this is the 12+1th page 
\end{document}
  • Thank you very much -- this is a quick solution too. The fancy page style created issues for me elsewhere, so I decided to go with the other proposed solution. Many thanks everyone. – Amir Ali Ahmadi Sep 11 at 10:50
  • 1
    @AmirAliAhmadi the fancyhdr package allow a ex­ten­sive con­trol of page head­ers and foot­ers so that issues probably can be solved with no effort, or maybe the footer can be fixed by another method without that package, but without a minimal working example showing these issues is not possible go further. – Fran Sep 11 at 11:07

The following solution sets page 13 as 12+1 in whichever format your page numbering is set to. It uses fancyhdr to set the page number in the Centre of the footer.

enter image description here

\documentclass{article}

\usepackage{lipsum,fancyhdr}

\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\renewcommand{\headrulewidth}{0pt}% Remove header rule
\fancyfoot[C]{%
  \ifnum\value{page}=13
   $\mbox{\setcounter{page}{12}\thepage} + \mbox{\setcounter{page}{1}\thepage}$%
   \setcounter{page}{13}%
  \else
    \thepage
  \fi
}

\pagenumbering{roman} % Just as an example

\begin{document}

\sloppy\lipsum[1-50]\lipsum[1-50]

\end{document}

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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