练习:多次打印练习文本(反复使用 \shipoutExercise)

练习:多次打印练习文本(反复使用 \shipoutExercise)

我正在为中学生排版试卷。我的想法是exercise.sty在辅导课上将答案打印在“试卷”的背面。

我还想节省纸张:因为每次“考试”只包含 2-3 个问题,它们只能容纳半张 A4 纸 - 因此,我们的想法是让每张 A4 纸有两张“考卷”,然后从中间剪开纸张。

我希望\shipoutExercise命令exercise.sty能够打印两次问题。然而它却不行。下面的代码只排版了一次问题(和答案)。

有可能找到解决这个问题的方法吗?

最小(不)工作示例:

\documentclass[12pt]{article}

\pagestyle{empty}

\usepackage[lastexercise,answerdelayed,exercisedelayed]{exercise}

\begin{document}

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

\shipoutExercise % print problems the 1st time

\shipoutExercise % print them the second time

%-------------
\newpage
\shipoutAnswer % print answers the first time

\shipoutAnswer % print them the second time


\end{document}

这是一个简化版本。在实际生活中,\shipout...命令将被包裹起来minipage以恰好填充 A4 页面的 50%。

答案1

我找到了一个快速而粗糙的解决方案:重新定义\shipout...文档中的命令并确保相应的框在排版后不会被清空。

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

希望有一个更好的(更优雅 - 例如,带有封装选项?)解决方案。

相关内容