# Exercise: print exercise text several times (use \shipoutExercise repeatedly)

I am typesetting exams for secondary school students. The idea is to use exercise.sty to be able to print the answers on the back of the "exam sheet" during a tutorial.

I also want to save paper: as each "exam" contains only 2-3 problems, they fit in a half of A4 - so, the idea is to have two "exam sheets" per A4 and then cut the paper in the middle.

My hope was that the \shipoutExercise command of exercise.sty would allow printing the problems twice. However it does not. The code below typesets the problems (and the answers) only once.

Is it possible to find a workaround for this issue?

Minimal (not) working example:

\documentclass[12pt]{article}

\pagestyle{empty}

\begin{document}

\begin{Exercise}
This is problem's text: how many?
\end{Exercise}
5 pieces

\shipoutExercise % print problems the 1st time

\shipoutExercise % print them the second time

%-------------
\newpage

\shipoutAnswer % print them the second time

\end{document}


This is a simplified version. In the real life, the \shipout... commands will be wrapped in minipage to fill exactly 50% of an A4 page.

I have found a quick and dirty solution: by redefining the \shipout... commands in my document and making sure the corresponding boxes not get emptied after being typeset.

\makeatletter
\renewcommand{\shipoutExercise}{%
\global\setbox\temp@Exercisebox\copy\all@Exercisebox%
\if@ExerciseOutput\unvbox\all@Exercisebox\fi%
\global\setbox\all@Exercisebox\copy\temp@Exercisebox%
}