[texhax] Repeating an environment
Herbert Voss
Herbert.Voss at FU-Berlin.DE
Wed Apr 29 09:15:15 CEST 2009
Stefan Björk schrieb:
>> \documentclass{article}
>> \usepackage{multido}
>> \begin{document}
>> \newcommand{\textToRepeat}{A lot of text over several pages.\par This is
>> run number \i.\par}
>> \multido{\i=1+1}{5}{\textToRepeat}
>> \end{document}
>
> Thank you! -- but I would really like to implement it as an
> environment, not macro. Is that possible?
\documentclass{article}
\usepackage{multido}
\newsavebox\TBox
\newcommand*\RepeatN{}
\newenvironment{Repeat}[1][1]
{\renewcommand*\RepeatN{#1}%
\begin{lrbox}{\TBox}
\begin{minipage}{\linewidth}}
{\end{minipage}\end{lrbox}%
\multido{\iA=0+1}{\RepeatN}{\usebox\TBox\endgraf}}
\begin{document}
foo
\begin{Repeat}[3]
A lot of text over several pages.\par
A lot of text over several pages.
\end{Repeat}
\end{document}
Herbert
More information about the texhax
mailing list