框架小页面和“评论”包

框架小页面和“评论”包

我正在准备一本有两个版本的课堂练习册:一个有答案,一个没有答案。学生版有大而空的方框,可以手写答案。教师版有建议的答案,写在这个方框里。我必须手动保证方框足够大,以便学生可以写进去。

两个版本的分页必须一致,因此我使用固定高度的框架小页面。小页面不应跨越分页符。

framebox使用下面的 MWE,命令和包之间似乎存在冲突:如果我删除环境comments的行comments

\begin{teacher}
\end{teacher}

框架运行良好。

或者,如果我删除该framebox命令,该comments包仍能完美运行。

但如果我同时保留框架和评论环境,它就会失败,并报告 Paragraph ended before \xComment was complete

我怎样才能同时获得两者?最终,我希望教师版本包含更复杂的东西,例如基于多语种的语言和图像。有没有更简洁的方法来实现我想要的效果?

这是 MWE

\documentclass[12pt]{report}
\usepackage{comment}
\includecomment{teacher}
\begin{document}
Please answer this question in the box below:
\bigskip
\framebox{%
\begin{minipage}[0in][5in][t]{\textwidth}
\begin{teacher}
This is a a sample answer from the teacher
\end{teacher}
\end{minipage}
}
\end{document}

答案1

这能满足您的需求吗?下面我用两种情况来展示它:包含和排除注释。我还添加了,\mbox{}以便minipage在其他位置为空时显示为全宽。

编辑以使缩进正确。但是,我仍然无法将该方法压缩到其自己的环境中,因为环境似乎teacher对其打包方式非常挑剔。

\documentclass[12pt]{report}
\fboxsep=10pt\fboxrule=1pt
\usepackage{comment}
\includecomment{teacher}
\begin{document}
Please answer this question in the box below:
Please answer this question in the box below:
Please answer this question in the box below:
Please answer this question in the box below:
Please answer this question in the box below:
\bigskip\par
\noindent\setbox0=\hbox{%
\noindent\begin{minipage}[0in][5in][t]{\textwidth}%
\begin{teacher}
This is a a sample answer from the teacher
This is a a sample answer from the teacher
This is a a sample answer from the teacher
This is a a sample answer from the teacher
This is a a sample answer from the teacher
This is a a sample answer from the teacher
This is a a sample answer from the teacher
This is a a sample answer from the teacher
\end{teacher}
\mbox{}%
\end{minipage}%
}%
\hspace{\dimexpr-\fboxsep-\fboxrule\relax}\framebox{\box0}
\clearpage
\excludecomment{teacher}
Please answer this question in the box below:
\bigskip\par
\noindent\setbox0=\hbox{%
\noindent\begin{minipage}[0in][5in][t]{\textwidth}%
\begin{teacher}
This is a a sample answer from the teacher
\end{teacher}
\mbox{}%
\end{minipage}%
}%
\hspace{\dimexpr-\fboxsep-\fboxrule\relax}\framebox{\box0}
\end{document}

在此处输入图片描述

答案2

或者,看看这个tcolorbox包或其他类似的包,你可以完全调整它们以满足你的需求。它与你的评论包配合得很好。

\usepackage{tcolorbox}

\begin{tcolorbox}
\begin{minipage}[0in][5in][t]{\textwidth}
\begin{teacher}
This is a a sample answer from the teacher
\end{teacher}
\end{minipage}
\end{tcolorbox}

相关内容