如果子问题在同一个完形填空问题中,我看不出一个简单的方法来做你想做的事。但是,如果您将它们放入单独的练习中,则通过自定义模板“相对”简单。
假设您有两个项目item1.Rmd(编号与 1+1 练习)和item2.Rmd(编号与 2+2 练习)。然后您需要三个模板:preparation.tex、oral.tex 和 combined_solution.tex。前两个通常隐藏解决方案环境,而后者显示它。此外,前两个没有显示所有练习,而后一个显示。更多详细信息在下面和vignette("exams", package = "exams") 的第 3 节中。然后就可以了
`exams2pdf(c("item1.Rmd", "item2.Rmd"), n = 3,
template = c("preparation.tex", "oral.tex", "combined_solution.tex"))
combined_solution.tex 模板显示问题和解决方案以及所有练习:
\documentclass[a4paper]{article}
...
\newenvironment{question}{\item \textbf{Problem}\newline}{}
\newenvironment{solution}{\textbf{Solution}\newline}{}
...
\begin{document}
\begin{enumerate}
%% \exinput{exercises}
\end{enumerate}
\end{document}
preparation.tex 只显示第一个练习(而不是第二个)并隐藏了求解环境:
\documentclass[a4paper]{article}
...
\newenvironment{question}{\item \textbf{Problem}\newline}{}
\newenvironment{solution}{\comment}{\endcomment}
...
\begin{document}
\begin{enumerate}
\input{exercise1.tex}
\item \emph{Oral part.}
\end{enumerate}
\end{document}
相反,oral.tex 只显示第二个练习(而不是第一个)并隐藏解决方案环境:
\documentclass[a4paper]{article}
...
\newenvironment{question}{\item \textbf{Problem}\newline}{}
\newenvironment{solution}{\comment}{\endcomment}
...
\begin{document}
\begin{enumerate}
\item \emph{Preparation part.}
\input{exercise2.tex}
\end{enumerate}
\end{document}
除了将\item \emph{...} 包含在隐藏练习中,您还可以增加计数器或使用嵌套的{enumerate} 环境或类似的东西。