自从考试类更新到 2.6 版后,我就不能再使用依赖于第一个问题之前的 \printanswers 的自定义环境了。(我使用这解决方案。)
通过考试 2.5 级,我能够做到
\documentclass{exam}
\usepackage{framed}
\newenvironment{note}{%
\ifprintanswers
\begin{framed}\noindent\textbf{Note:}\par\noindent
\else
\setbox0\vbox\bgroup
\fi
}{%
\ifprintanswers
\end{framed}%
\else
\egroup
\fi%
}
\printanswers
%\noprintanswers
\begin{document}
\begin{questions}
\begin{note}
this is a note
\end{note}
\question
question
\begin{solution}
this is the solution
\end{solution}
\begin{note}
this is another note
\end{note}
\end{questions}
\end{document}
但是在考试级别 2.6 中我总是收到这个错误:
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.25 \end{note}
答案1
解决方案是将第一个注释环境移出问题环境。使用注释包的替代解决方案导致了与上述相同的错误。
\documentclass{exam}
\usepackage{framed}
\newenvironment{note}{%
\ifprintanswers
\begin{framed}\noindent\textbf{Note:}\par\noindent
\else
\setbox0\vbox\bgroup
\fi
}{%
\ifprintanswers
\end{framed}%
\else
\egroup
\fi%
}
\printanswers
%\noprintanswers
\begin{document}
\begin{note}
this is a note
\end{note}
\begin{questions}
\question
question
\begin{solution}
this is the solution
\end{solution}
\begin{note}
this is another note
\end{note}
\end{questions}
\end{document}