7

Is there a way to add pages to the middle of a document in such a way that they are not only unnumbered but also do not add to the overall sequence of numbered pages?

Like this:

page 1
page 2
page 3
extra-numerary page
page 4
extra-numerary page
extra-numerary page
page 5

I do not know the actual page count at any moment; this is calculated by LaTeX.

2
  • 3
    \clearpage\thispagestyle{empty}\addtocounter{page}{-1} extra stuff \clearpage should work Jan 21, 2014 at 23:51
  • See also package pdfpages.
    – Speravir
    Jan 22, 2014 at 0:28

2 Answers 2

9

This is a slightly different approach. I thought it might be useful to have a solution with the following features:

  • no need to adjust the page count manually;
  • works no matter how many pages the text in the unnumbered section requires;
  • uses empty for the page style of the unnumbered section (but could be adapted to use a modified version of another page style such as headings);
  • is independent of the page style in use for the rest of the document.

For example, you might not know how many pages the text in the unnumbered section requires. Moreover, this might change if you adjust the formatting later and it is a pain to have to remember to adjust the page settings manually in that case.

However, there may be disadvantages to this solution of which I'm currently unaware. (I strongly suspect this since this solution hasn't been suggested by wiser heads than mine!)

\documentclass{article}
\newcounter{mypagecount}% create a new counter
\setcounter{mypagecount}{0}% set it to something just in case
\newenvironment{interlude}{% create a new environment for the unnumbered section(s)
  \clearpage
  \setcounter{mypagecount}{\value{page}}% use the new counter we created to hold the page count at the start of the unnumbered section
  \thispagestyle{empty}% we want this page to be empty (adjust to use a modified page style)
  \pagestyle{empty}% use the same style for subsequent pages in the unnumbered section
  }{%
  \clearpage
  \setcounter{page}{\value{mypagecount}}% restore the incremented value to the official tally of pages so the page numbering continues correctly
  }
\usepackage{lipsum}

\begin{document}

\lipsum[1-5]

\begin{interlude}
    \section{A new section}

    \lipsum[7-8]

    \subsection{A subsection}

    \lipsum[11]
\end{interlude}

\lipsum[12-15]

\end{document}

Note that because \pagestyle{empty} is limited to the interlude environment, we don't need to restore the pagestyle manually at the end of the environment as LaTeX takes care of this automatically. So if the document used headings, for example, rather than plain, the correct style would be restored at the end of the unnumbered interlude.

This produces:

An unnumbered middle which is not counted

2
  • \setcounter{mypagecount}{\value{page}} should be after \clearpage, when you know for sure what it is. No need to \stepcounter{mypagecount} with this change.
    – egreg
    Jan 22, 2014 at 7:32
  • @egreg Thanks, you're right, of course - the original version could sometimes give the wrong result. Updated accordingly.
    – cfr
    Jan 22, 2014 at 14:06
7

According to @DavidCarlisle comment, you can insert the extra stuff using the commands

\clearpage\thispagestyle{empty}\addtocounter{page}{-1} extra stuff \clearpage

The idea is very simple: just add minus 1 to the page counter and hide the page numbering using the empty page style.

Here is a minimal example.

\documentclass{report}
\begin{document}

this is page number~\thepage

\clearpage\thispagestyle{empty}\addtocounter{page}{-1} 
this is page number~\thepage\ but the page number is not show
\clearpage

this is page number~\thepage

\end{document}

enter image description here

You must log in to answer this question.

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