8

Is it possible to 'trick' LaTeX into displaying different page numbers?

For a whole host of complicated reasons I would like to display

1 instead of 7

2 instead of 8

3 instead of 9

etc....

without changing the page counter. Is this needlessly tricky?

  • Difficult to say without some more details; how should the pages before page 7 (to be displayed as 1) be numbered? – egreg Apr 14 '15 at 13:43
  • Those numbers will be suppressed so wont be displayed. – Juggler Apr 14 '15 at 13:46
  • Modifying \thepage is allowed, but not the counter? – user31729 Apr 14 '15 at 13:49
  • If that's possible? – Juggler Apr 14 '15 at 13:50
  • Maybe create a new counter page and use it in the page style? – Sigur Apr 14 '15 at 13:52
6

This version (modified from egreg) would work with hyperref

\documentclass{article}
\usepackage{hyperref}

\begin{document}

\pagenumbering{Roman}
\pagestyle{empty}

This page has no number\newpage %1

This page has no number\newpage %2

This page has no number\newpage %3

This page has no number\newpage %4

This page has no number\newpage %5

This page has no number %6

\clearpage
\pagenumbering{arabic}
\pagestyle{headings}

This is page 1\newpage

This is page 2

\end{document}

The problem when using \pagenumbering{gobble} with hyperref is that you get warnings because several pages have the same identifier and the pdf-page numbering is broken. If you have no problem with the empty pages being numbered with roman numerals in the pdf-pagecount but not in the print area of the file, then this should work.

  • This adds other problems if the page style shouldn't be empty. – egreg Apr 14 '15 at 14:10
  • @egreg That is certainly true. It only solves the problem assuming that Juggler added all necessary information. – Manuel Weinkauf Apr 14 '15 at 14:14
3

If you don't need hyperref, the trick is very easy:

\documentclass{article}

\begin{document}

\pagenumbering{gobble}

This page has no number\newpage %1

This page has no number\newpage %2

This page has no number\newpage %3

This page has no number\newpage %4

This page has no number\newpage %5

This page has no number %6

\clearpage
\pagenumbering{arabic}

This is page 1\newpage

This is page 2

\end{document}
  • I am using hyperref is that an issue? – Juggler Apr 14 '15 at 13:53
  • 3
    @Juggler Yes, of course it is. Please, add details to your question. – egreg Apr 14 '15 at 13:58
3

Perhaps this works

\documentclass{article}

\def\pageoffset{6}  %(7 - 1 = 6)

\usepackage{etoolbox}
\usepackage{blindtext}
\usepackage{hyperref}
\let\origthepage\thepage
\renewcommand{\thepage}{%
\ifnumgreater{\value{page}}{1}{\number\numexpr\value{page}+\numexpr\pageoffset-1}{\origthepage}
}

\begin{document}
\pagestyle{empty}
\tableofcontents
\listoffigures
\listoftables
\clearpage

\pagestyle{plain}

\section{First}
\blindtext[30]
\section{Other}
\end{document}

I omitted a screenshot, it shows the feature (for a small document, untested for a larger one). hyperref works in here

Edit A better version, taking care of the current page value:

\documentclass{book}


\usepackage{etoolbox}
\usepackage{blindtext}
\usepackage{hyperref}


\def\pageoffset{6}%
\newcounter{pagereset}
\let\latexthepage\thepage

\newcommand{\SwitchPagenumbering}{%
  \setcounter{pagereset}{\number\value{page}}%
  \renewcommand{\thepage}{%
    \ifnumgreater{\value{page}}{\value{pagereset}-1}{\number\numexpr\value{page}+\number\numexpr\pageoffset}{\latexthepage}%
  }%
}


\begin{document}
\pagenumbering{Roman}
\tableofcontents
\listoffigures
\clearpage
\pagenumbering{arabic}

\SwitchPagenumbering


\chapter{First}
\section{First}

\blindtext[30]
\typeout{Pagereset is \thepagereset: Page is \number\value{page}}

\section{Other}
\blindtext[20]
\section{Other}
\section{Other}

\end{document}
  • I have not much time right now to provide a better version, so be patient ... – user31729 Apr 14 '15 at 14:07
  • I think, the page number before this resetting occurs, should be stored, to make the whole stuff more fail safe – user31729 Apr 14 '15 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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