两年前,我在考试包的解决方案环境中找到了包含脚注的解决方案:
https://tex.stackexchange.com/a/392622/96422
这个答案建议使用脚注包,它运行完美,但它有一个问题:当删除答案选项时,脚注仍然会出现在文档中,正如您所看到的修改引用答案中给出的相同示例:
\documentclass[12pt]{exam}
\usepackage{footnote}
\makesavenoteenv{solution}
\begin{document}
\begin{questions}
\question
Some question
\begin{solution}
Text\footnote{Some footnote that must not appear when answers option is
removed}
\end{solution}
\end{questions}
\end{document}
这意味着您必须注释掉每个脚注才能设置没有解决方案的考试。我希望解决方案中的脚注仅在answers
给出选项时显示。
答案1
我找到了使用脚注包中的其他命令的解决方案:\savenotes
和。它们包含一个组,其中保存脚注并在最后执行。它们只能在使用考试类定义的\spewnotes
布尔值打印答案时使用:\ifprintanswers
\documentclass[12pt,answers]{exam}
%\documentclass[12pt]{exam}
\usepackage{footnote}
%\makesavenoteenv{solution}
\begin{document}
\begin{questions}
\question
Some question
\ifprintanswers
\savenotes
\fi
\begin{solution}
Text\footnote{Some footnote that must not appear when answers option is
removed}
\end{solution}
\ifprintanswers
\spewnotes
\fi
\end{questions}
\end{document}
重新定义考试包的环境以包含这些命令可能是值得的TheSolution
(基于考试目录):
\makeatletter
\renewenvironment{TheSolution}%
{%
\savenotes%
\vspace{\parskip}%
% If we don't set \leftskip and \rightskip to 0pt, then if we
% appear inside of an \uplevel command we'd have indentation
% inside of the solution box:
\leftskip=0pt
\rightskip=0pt
% If the user said \unframedsolutions, then both
% \if@framedsolutions and \if@shadedsolutions are false:
\if@framedsolutions
% We'll use the default \exam@FrameCommand
\else
\if@shadedsolutions
\def\exam@FrameCommand{\colorbox{SolutionColor}}%
\else
% It's \unframedsolutions:
\def\exam@FrameCommand{}%
\fi
\fi
\exam@MakeFramed{\advance\hsize-\exam@width}%
\solutiontitle
\ignorespaces
}%
{%
\unskip
\endexam@MakeFramed
\spewnotes
}%
\makeatother
一个可能的问题是,如果在问题陈述中使用脚注,则当未打印答案时,这些脚注的编号将出现跳跃。