I am trying to duplicate a document using hooks at the beginning and the end. Here is a minimal example of my problem :
\documentclass{minimal}
\usepackage{environ}
\usepackage{forloop}
%Repeat text
\newcounter{loopcntr}
\newcommand{\rpt}[1]{
\forloop{loopcntr}{0}{\value{loopcntr}<2}{#1}
}
%Create an environment to repeat text
\NewEnviron{rptenv}{
\rpt{\BODY}
}
\AtBeginDocument{
\begin{rptenv}
}
\AtEndDocument{
\end{rptenv}
}
\begin{document}
Hello.
\end{document}
Why doesn't it work ? If I replace "rptenv" in the hooks by "center", it works like a charm. Is there another way to achieve an automated repetition without changing anything in the body of the file ?
\end{rptenv}to stop the parsing. You can't hide it in\end{document}. http://tex.stackexchange.com/questions/218589/runaway-argument-error-with-newenviron. I would put the content of the document in some external file and do the loop over\input{content}. – Ulrike Fischer Aug 27 '15 at 15:13