[Tex/LaTex] Empty document, only pagenumber, 500 pages needed

koma-scriptloopspage-numbering

I need a document with 500 empty pages, only the pagenumbering in the foot of the page.

This MWE shows 2 pages in the way I'd like to get all 500:

\documentclass[pagenumber=footright, DIV=20, fontsize=16]{scrartcl}
\usepackage[automark]{scrlayer-scrpage}
\pagestyle{scrheadings}
\ihead{}
\ofoot[\pagemark]{\pagemark}
\chead{}
\cfoot[]{}
\ohead{}



\begin{document}
\mbox{}


\newpage

\mbox{}
\newpage



\end{document}

Can somebody write e.g. a loop for 500 pages? Cave: the \mbox{} is necessary, otherwise there is no pagenumber or even a PDF of 0 pages…

(The purpose is to add pagenumbers to an already printed document: I'll put the 500 pages again into the printer and thus get a printed document with pagenumbers. I'm trying to help a poor guy here who otherwise had to write the pagenumbers manually into 40 folders à 500 pages.)

Best Answer

Use a primitive \loop with \repeat and \unless testing.

\documentclass[pagenumber=footright, DIV=20, fontsize=16]{scrartcl}
\usepackage[automark]{scrlayer-scrpage}
\pagestyle{scrheadings}
\ihead{}
\ofoot[\pagemark]{\pagemark}
\chead{}
\cfoot[]{}
\ohead{}


\newcounter{loopcntr}

\begin{document}
\loop\unless\ifnum\value{loopcntr}=500
\mbox{}
\newpage
\stepcounter{loopcntr}% Advance the counter
\repeat

\end{document}

Here's a variant with pgffor and forloop packages:

\documentclass[pagenumber=footright, DIV=20, fontsize=16]{scrartcl}
\usepackage[automark]{scrlayer-scrpage}
\pagestyle{scrheadings}
\ihead{}
\ofoot[\pagemark]{\pagemark}
\chead{}
\cfoot[]{}
\ohead{}

\usepackage{pgffor}
\usepackage{forloop}

\newcounter{loopcntr}

\begin{document}

\foreach \x in {1,...,500} {%
\mbox{}
\newpage
}

\forloop{loopcntr}{1}{\value{loopcntr} < 501}{%
\mbox{}
\newpage
}


\end{document}
Related Question