1

Two years ago I found this solution for including footnotes in the solution environment of the exam package:

https://tex.stackexchange.com/a/392622/96422

This answer propose to use the footnote package, and it works perfectly, but it has a problem: when the answer option is removed, the footnote still appears in the document, as you can see modifying the same example given in the referenced answer:

\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}

enter image description here

That means that you have to comment out each footnote to set up an exam without solutions. I would like the footnotes in the solutions to only show when answers options is given.

0

I have found a solution using other commands in footnote package: \savenotes and \spewnotes. They enclose a group where the footnotes are saved and executed at the end. They can be used only when answers are being printed with the boolean \ifprintanswers defined by exam class:

\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}

It may be worthy to redefine the TheSolution enviroment of the exam package to include those commands (based on the original code of exam.cls):

\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

A possible problem is that if footnotes are used in the question statements, there will be jumps in the numbering of those footnotes when the answers are not printed.

1
  • 1
    Use symbols? († ‡ ⸸ ⸶ ⸷).
    – Oni
    Jun 9 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.