[Tex/LaTex] Page numbers only on even pages

page-numbering

I need to put page numbers only on even pages:

  • Page 1, no page number.
  • Page 2, number 1.
  • Page 3, no page number.
  • Page 4, number 2.
  • Page 5, no page number.
  • Page 6, number 3.

I guess I need to mess a bit with the page numbering system like a \renewcommand{\thepage} that would divide the page by two or check if it's even?

\documentclass{article}

\begin{document}
No page number \newpage Should be 1 \newpage
No page number \newpage Should be 2 \newpage
No page number \newpage Should be 3 \newpage
\end{document}

Best Answer

Here's a solution that uses the fancyhdr package to redefine the plain page style. The logic is simple. The page number is not printed if it's odd. If it's even, the page number is divided by two and then printed.

Note that this doesn't change actual page number, so cross references and table of contents will be wrong if you use them. But I'm not sure how to avoid this if you are not numbering every page.

\documentclass{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
\makeatletter
\newcount\halfpage
\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyfoot[C]{%
    \ifodd\c@page
    \else
      \halfpage=\c@page
      \divide\halfpage by 2
      \@arabic{\halfpage}%
    \fi}%
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0pt}}
\makeatother
\pagestyle{plain}
\begin{document}
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\end{document}
Related Question