9

Is there a single command with which one can insert an arbitrary number of blank pages inside some latex text?

4 Answers 4

5

I don't know any, but this should work:

\newcount\ipp
\ipp=0
\newcount\numberOfPages
\numberOfPages=10 % or else; never 0!!! 
\loop
\newpage
\mbox{}
\advance\ipp by1
\ifnum\ipp<\numberOfPages\repeat

If you package it into a newcommand, it looks like this:

\newcommand{\fillInPages}[1]{
\newcount\ipp
\ipp=0
\newcount\numberOfPages
\numberOfPages=#1 
\loop
\newpage
\mbox{}
\advance\ipp by1
\ifnum\ipp<\numberOfPages\repeat
}
0
6

With xparse we can use \prg_replicate:nn

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\blankpages}{O{}m}
 {
  \clearpage
  \prg_replicate:nn { #2 } { #1 \mbox{} \clearpage }
 }
\ExplSyntaxOff

\begin{document}

% ten blank pages with page number
\blankpages{10}

% four really blank pages
\blankpages[\thispagestyle{empty}]{4}

% four “intentionally blank page”
\blankpages[
  \thispagestyle{empty}
  \vspace*{\fill}
  \begin{center}
  This page intentionally blank
  \end{center}
  \vspace*{\fill}
]{4}

\end{document}
5

Here another possibility using a recusrion:

\documentclass{article}
\usepackage{lipsum}

\makeatletter
\newcommand\blankpage[1][1]{%
  \ifnum#1<0\else
    \@tempcnta#1
    \@tempcntb\z@
    \bl@nkpage
  \fi
}
\newcommand\bl@nkpage{%
  \bl@nkp@ge
  \advance\@tempcntb\@ne
  \ifnum\@tempcntb<\@tempcnta
    \bl@nkpage
  \fi
}
\newcommand\bl@nkp@ge{\clearpage\thispagestyle{empty}\null\clearpage}
\makeatother

\begin{document}
\lipsum
\blankpage[3]
\lipsum
\end{document}

If you want to be a little more sophisticated you could add a starred version of \blankpage that keeps the page style as is:

\documentclass{article}
\usepackage{lipsum}

\makeatletter
\newcommand\blankpage{%
  \begingroup
  \@ifstar
    {\let\thispagestyle\@gobble\blankpage@}
    {\blankpage@}
}
\newcommand\blankpage@[1][1]{%
  \ifnum#1<0\else
    \@tempcnta#1
    \@tempcntb\z@
    \bl@nkpage
  \fi
}
\newcommand\bl@nkpage{%
  \bl@nkp@ge
  \advance\@tempcntb\@ne
  \ifnum\@tempcntb<\@tempcnta
    \bl@nkpage
  \else
    \endgroup
  \fi
}
\newcommand\bl@nkp@ge{\clearpage\thispagestyle{empty}\null\clearpage}
\makeatother

\begin{document}
\blankpage*[3]
\blankpage[2]
\blankpage*
\end{document}
4

Users of ConTeXt can use a combination of the \page and \dorecurse commands to insert a certain number of empty pages.

When the page should be empty without headers and footers the empty keyword can be used as argument for the \page command.

\starttext
\dorecurse{10}{\page[empty]}
\stoptext

When the empty pages should contain the header and footer texts the dummy keyword can be used.

\starttext
\dorecurse{10}{\page[dummy]}
\stoptext

You must log in to answer this question.

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