3

I'm using exam package, I would like to add a footnote to a solution: it displays the mark but not the note text. In question environment it is all right.

\documentclass[12pt, answers]{exam}
%\documentclass[12pt]{exam}
\usepackage[english, italian]{babel}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage[usenames,dvipsnames]{color}
\usepackage[utf8x]{inputenc}
\usepackage{verbatim}
\usepackage{minted}
\usepackage{footnote}
\renewcommand{\solutiontitle}{\noindent\textbf{Risposta:}\enspace}

\newcommand{\col}[1]{{\color[rgb]{0.094,0.235,0.36}{#1}}}
\newcommand{\myt}[1]{\textbf{\col{#1}}}
\newcommand{\myhdr}[4]{
\pagestyle{headandfoot}
\firstpageheader{\myt{#1}}{\Huge\myt{#2}}{\myt{#3}}
\runningheader{\myt{#1}}{\Huge\myt{#2}}{\myt{#3}}
\firstpagefooter{}{\myt{#2}}{\myt{#4}}
\runningfooter{}{\myt{#2}}{\myt{#4}}
\runningfootrule
}


%\myhdr{3A - INT}{Domande da un minuto}{Sistemi}{Pag. \thepage\ - \numpages}
\checkboxchar{$\Box$}


\begin{document}
\begin{questions}
\section{Capitolo 1}
\subsection{Quizzes}


\subsection{Questions}
\question
In quali parti si divide un \footnote{footnotes working fine} indirizzo IPv4?
    \begin{solution}Network portion e Host portion\footnote{footnotes working fine} \end{solution}


\section{Capitolo 8}
\subsection{Quizzes}
\subsection{Questions}
\question
In quanti livelli viene, di fatto, divisa la gerarchia della rete dal momento in cui aggiungo le sottoreti?
    \begin{solution}Tre: rete, sottorete e host\end{solution}
\question
Che cosa viene facilitato dalla creazione di un ulteriore livello nella gerarchia di rete?
    \begin{solution}La creazione dei sottogruppi nella rete IP che ne deriva facilita la velocizzazione di trasmissione dei pacchetti e la minimizzazione del traffico locale\footnote{8.0.1.1: Introducing an additional level to the hierarchy creates additional sub-groups within an IP network that facilitates faster packet delivery and added filtration, by helping to minimize ‘local’ traffic.}\end{solution}
\end{questions}
\end{document}

I would like to have it working even with my footer on, though commented in this example.

massi
  • 431

2 Answers2

4

You can use the footnote pacakge to obtain footnotes from within the exam class:

enter image description here

Code:

\documentclass[12pt, answers]{exam}

\usepackage{footnote} \makesavenoteenv{solution}

\begin{document} \begin{questions}

\question Some question \begin{solution} Text\footnote{Some footnote} \end{solution}

\end{questions} \end{document}

Peter Grill
  • 223,288
  • 3
    Thanks, it worked. Anyway, just using package footnote was of no help, until I added the \makesavenoteenv{solution} line. Could you please explain the little magic of that command? – massi Sep 22 '17 at 06:18
  • 3
    @massi: The \makesavenoteenv is used to specify for which environments, the \footnotes should be saved. – Peter Grill Sep 25 '17 at 02:18
  • It works, but it has a problem. When the answer option is removed, the footnote still appears in the document. – Sergio Llorente Jul 05 '18 at 17:35
  • @SergioLlorente: I think it best if you ask a new question and include a MWE including \documentclass and the appropriate packages that reproduces the problem. You can reference this question if it is relevant. – Peter Grill Jul 05 '18 at 20:01
  • I wasn't getting the footnote text even for footnotes outside of solution environments. So to expand on @PeterGrill's comment, you can turn them on everywhere with \makesavenoteenv{questions} (though for some reason \makesavenoteenv{document} doesn't work). – Annie Carter Oct 23 '23 at 05:04
  • Actually, \makesavenoteenv{questions} isn't a good option, because it throws the footnote to the page when the questions environment ends. I ended up putting the paragraph containing my footnote into a full-width minipage, and used \makesavenoteenv{minipage} with success. – Annie Carter Oct 25 '23 at 04:55
0

I use endnotes (with the enotez package) in this context, and it seems to work smoothly. When I just want the exam without solutions, I comment out the \printendnotes line at the end to not display the endnotes at all.

  • This seems better-suited as a comment, as it provides an alternative approach to \footnotes rather than solving the problem. – Werner Mar 15 '21 at 15:06