7

I would like to change the page numbering of my document to include pi, such that the order is: 1, 2, 3, \pi, 4, 5, and so on. I have moved page number 4 to the fifth page by including

\clearpage
\setcounter{page}{4}

on the fourth page, but how do I customize the number on the fourth page?

(I am using memoir, in case it matters.)

7
  • 2
    e=2.718281828 is missing then too ;-)
    – user31729
    Apr 23, 2016 at 10:08
  • 1
    @ChristianHupfer I know. I'll get there. ;-)
    – Thomas
    Apr 23, 2016 at 10:10
  • Is the page specific, i.e. a particular page that shall be numbered this way or is it just changing the 4th page to be pi?
    – user31729
    Apr 23, 2016 at 10:11
  • @ChristianHupfer I am not sure what you mean. The page numbering is done automatically at this point, such that my introduction starts on page 1 and ends on page 4. It doesn't matter which content is present on page \pi or page 4. I just want to shift the numbering one page in order to include pi. (Just for fun, not a necessity.)
    – Thomas
    Apr 23, 2016 at 10:15
  • This sounds extremely confusing to readers. Why do you want to do this? Apr 23, 2016 at 12:21

1 Answer 1

13

In total, I don't recommend this pagenumbering at all, since it will lead to recto pages with even page numbers.

The output of \thepage must be changed -- either use a \renewcommand{\thepage}{....} or a more clever way, see the example at the bottom of this answer with \pagenumbering{weird} ;-)

Here's a version that changes the 4th page number to be \pi and continues with 4 then.

Please note that \pagenumbering etc does change the numbering again and hyperref could be confused by this!

\documentclass{memoir}

\usepackage{everypage}
\usepackage{blindtext}
\newif\ifpipage
\let\thepageorig\thepage
\AddEverypageHook{%
  \ifnum\value{page} = 4
  \renewcommand{\thepage}{$\pi$}%
  \global\pipagetrue
  \else
  \ifpipage
  \addtocounter{page}{-1}
  \global\pipagefalse
  \fi
  \let\thepage\thepageorig
  \fi
}


\begin{document}

\blindtext[50]


\end{document}

Better version

\documentclass{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}


\makeatletter
\newcommand{\@weird}[1]{%
\ifnum#1< 4
\@arabic{#1}%
\else
\ifnum#1=4   
\texorpdfstring{\large$\pi$}{π}%
\else
\@arabic{\numexpr#1-1}%
\fi
\fi
}


\makeatother


\usepackage{hyperref}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\clearpage
\pagenumbering{weird}
\chapter{First}
\blindtext[50]
\chapter{Second}
\blindtext[50]
\end{document}

enter image description here

Other version -- now with \sqrt{2}, e and \pi ;-)

\pagenumbering{nerdy} does it all ;-)

\documentclass{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage{blindtext}

\usepackage{hyperref}


\newif\ifusesymbols
\usesymbolstrue

\makeatletter


\ifusesymbols
\newcommand{\sqrttwocontent}{\texorpdfstring{$\sqrt{2}$}{2\textsuperscript{0,5}}}
\newcommand{\eulercontent}{\texorpdfstring{$e$}{e}}
\newcommand{\picontent}{\texorpdfstring{$\pi$}{π}}
\else
\newcommand{\sqrttwocontent}{\num{1.41421}}
\newcommand{\eulercontent}{\num{2.71828}}%
   \newcommand{\picontent}{\num{3.14159}}%
\fi

\newcommand{\@weird}[1]{%
\ifnum#1< 4
\@arabic{#1}%
\else
\ifnum#1=4   
\picontent
%\texorpdfstring{\large$\pi$}{π}
\else
\@arabic{\numexpr#1-1}
\fi
\fi
}


\newcommand{\@nerdy}[1]{%
  \boldmath
  \ifnum#1< 2
  \@arabic{#1}%
  \else
  \ifcase#1
  \or\or
  \sqrttwocontent
  \or
  \eulercontent%
  \or \picontent%
  \else
  \@arabic{\numexpr#1-1}%
  \fi
  \fi
\unboldmath
}






\makeatother


\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\clearpage
\pagenumbering{nerdy}
\chapter{First}
\blindtext[3]
\section{Foo}
\blindtext[4]
\chapter{Second}
\blindtext[3]
\section{Foobar}
\blindtext[3]
\end{document}

enter image description here

8
  • Other idea: Use something like \pagenumbering{weird} ;-)
    – user31729
    Apr 23, 2016 at 10:31
  • This is very nice, but it turns out that it messes up the roman numbering in my frontmatter. Although I generally avoid working like this, is there any way to do the page numbering "locally"?
    – Thomas
    Apr 23, 2016 at 10:35
  • @Thomas: See the update
    – user31729
    Apr 23, 2016 at 10:38
  • 1
    @Thomas: It's a typographical standard rather. Recto page -> odd page number, verso page -> even page number. Chapters open on odd numbered pages as well. If this is alright for you, all is well ;-)
    – user31729
    Apr 23, 2016 at 11:44
  • 2
    @Thomas I would replace 3 by PI, so the recto-verso thing isn't messed up. 1, 2, PI, 4, 5,... Apr 23, 2016 at 14:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .