Latex:如何获取考试包中的问题编号

Latex:如何获取考试包中的问题编号

我正在使用考试包,我想以脚注的形式向某些解决方案添加扩展,其编号与问题编号相同,如下所示

\documentclass[12pt, answers]{exam}
\renewcommand{\solutiontitle}{\noindent\textbf{Risposta:}\enspace}
\checkboxchar{$\Box$}


\begin{document}
\begin{questions}
\section{Capitolo 1}
\question
which question am I?
\begin{solution}One \end{solution}

\question
which question am I, instead?
\begin{solution}Two \end{solution}

\question
How do I get the question current number?
    \begin{solution} Three \footnote[\questionnumber]{I would like this footnote to be numbered the same as the question} \end{solution}

\end{questions}


\end{document}

不幸的是,脚注根本不会出现(正如Latex:\footnote 命令在考试包的解决方案环境中不起作用)。

答案1

考试使用计数器question来做题。

\documentclass[12pt, answers]{exam}
\renewcommand{\solutiontitle}{\noindent\textbf{Risposta:}\enspace}
\checkboxchar{$\Box$}

\newcommand*\countoff[1]% #1 = counter name
{\ifcase\value{#1}{??}\or{One}\or{Two}\or{Three}\or{Four}\or{Five}%
   \or{Six}\or{Seven}\or{Eight}\or{Nine}\or{Ten}% ad infinitum
 \else{??}%
 \fi
}

\begin{document}
\begin{questions}
\section{Capitolo 1}
\question
which question am I?
\begin{solution}\thequestion \end{solution}

\question
which question am I, instead?
\begin{solution}\arabic{question} \end{solution}

\question
How do I get the question current number?
    \begin{solution}\countoff{question} \footnote[\thequestion]{I would like this footnote to be numbered the same as the question} \end{solution}

\end{questions}
\end{document}

答案2

您可以使用通常的\label/\ref机制。由于它正在使用,因此\footnote您需要先扩展它。我使用\xdef下面的方法执行此操作:

在此处输入图片描述

代码:

\documentclass[12pt, answers]{exam}
\renewcommand{\solutiontitle}{\noindent\textbf{Risposta:}\enspace}
\checkboxchar{$\Box$}

%% Need this to get footnote from within the exam class.
%% https://tex.stackexchange.com/a/392622/4301
\usepackage{footnote}
\makesavenoteenv{solution}

\newcommand{\ExamFootnote}[2]{%
    %% https://tex.stackexchange.com/q/50111/4301
    \xdef\currentQuestion{\ref{#1}}%
    \ifnum0<0\currentQuestion\else
        \def\currentQuestion{0}%
    \fi
    \footnote[\currentQuestion]{#2}%
}


\begin{document}
\begin{questions}
\section{Capitolo 1}
\question
    which question am I?
\begin{solution}
One 
\end{solution}

\question\label{question:This Question}
which question am I, instead?
\begin{solution}
    Two\ExamFootnote{question:This Question}{foot note for 2}
\end{solution}

\question\label{question:That Question}
How do I get the question current number?
\begin{solution} 
    Three \ExamFootnote{question:That Question}{I would like this footnote to be numbered the same as the question} 
\end{solution}

\end{questions}
\end{document}

答案3

我的一个朋友“现场”给了我一个更快捷、更简单的解决方案,所以我报告了它:

\documentclass[12pt, answers]{exam}
\renewcommand{\solutiontitle}{\noindent\textbf{Risposta:}\enspace}
\usepackage{footnote}
\makesavenoteenv{solution}

\begin{document}
\begin{questions}
\section{Capitolo 1}
\question
which question am I?
\begin{solution}One \end{solution}

\question
which question am I, instead?
\begin{solution}Two \end{solution}

\question
How do I get the question current number?
    \begin{solution} Three \footnote[\thequestiontitle]{I would like this footnote to be numbered the same as the question} \end{solution}

\end{questions}

\end{document}

根据包装文档(http://www-math.mit.edu/~psh/exam/examdoc.pdf),第 31 页

\thequestiontitle(参见第 4.5.2 节),扩展为

...

– 问题的编号(如果该问题是使用 \question 命令定义的)

相关内容