![考试包解决方案环境中的脚注](https://linux22.com/image/434963/%E8%80%83%E8%AF%95%E5%8C%85%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E7%8E%AF%E5%A2%83%E4%B8%AD%E7%9A%84%E8%84%9A%E6%B3%A8.png)
两年前,我在考试包的解决方案环境中找到了包含脚注的解决方案:
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
一个可能的问题是,如果在问题陈述中使用脚注,则当未打印答案时,这些脚注的编号将出现跳跃。