考试文档课程:如何对解决方案进行编号?

考试文档课程:如何对解决方案进行编号?

我正在尝试制作考试答案。我想要做的是制作一份仅有的答案。(从技术上讲,我计划将评分清单放入解决方案中 - 我希望在评分时在一页上看到尽可能多的问题清单)

我希望使用,\ifprintanswers但是当我使用 \thequestion 时\solutiontitle它总是显示为零。

此外,当我使用这种方法(基于我在 StackExchange 上找到的尾注方法)我需要先编译文档(使用 XeLaTeX)没有 \printanswers\printanswers,然后返回并在打开的情况下再次运行它。如果我不这样做,它会抱怨缺少.ent文件,我猜想这是存储尾注的地方。

\thequestion我希望有某种方法来捕捉我在没有它的情况下运行它时的值,\printanswers以便它在第二次运行时仍然存在。

梅威瑟:

\documentclass[addpoints, 12pt]{exam}

%TODO: Turn this on/off based on need for answer key
\printanswers
\unframedsolutions
% This will number the answers
% from https://tex.stackexchange.com/questions/284672/numbering-solutions-in-exam-environment#comment686934_284672
\renewcommand{\solutiontitle}{\noindent\textbf{Solution \thequestion:}}

% this exists to collect up the solutions/answers in one place:
% from https://tex.stackexchange.com/a/237849/131222
\usepackage{endnotes}

\def\enotesize{\normalsize}
\def\makeenmark{\relax}
\def\notesname{Answers}
\def\answer#1{\endnotetext{\vspace*{-3.5ex}\begin{solution}#1\end{solution}\unskip}}
\def\theanswers{\theendnotes \medskip}


\begin{document}


    \ifprintanswers % prints out the answer key, based on \printanswers in the preamble
        \newpage
        \theanswers
    \else % prints out the exam itself

    \begin{questions}

        \qformat{\large \textbf{Question:} \thequestion: \thequestiontitle\hfill(\thepoints)}


        \titledquestion{Syntax and Semantics}[30]
        \answer{Answer for Syntax and Semantics \thequestion DONE}

        \titledquestion{Second Question}[30]
        \answer{Answer for Second Question \protect \thequestion DONE}

        \titledquestion{Third Question}[30] 
        \answer{Answer for Third Question \protect \thequestion DONE}
    \end{questions}
    \fi


\end{document}

物有所值,当我关注这篇文章时,我也没能得到解决方案的数字

答案1

如果您检查该.ent文件,您会发现其中的所有宏均未\endnotetext展开。这意味着在第二次运行中,您将得到一堆没有问题的解决方案。至少,您需要增加问题计数器。

\documentclass[addpoints, 12pt]{exam}

%TODO: Turn this on/off based on need for answer key
\printanswers
\unframedsolutions
% This will number the answers
% from https://tex.stackexchange.com/questions/284672/numbering-solutions-in-exam-environment#comment686934_284672
\renewcommand{\solutiontitle}{\noindent\textbf{Solution \thequestion:~}}

% this exists to collect up the solutions/answers in one place:
% from https://tex.stackexchange.com/a/237849/131222
\usepackage{endnotes}

\def\enotesize{\normalsize}
\def\makeenmark{\relax}
\def\notesname{Answers}
\def\answer#1{\endnotetext{\vspace*{-3.5ex}\stepcounter{question}\begin{solution}#1\end{solution}\unskip}}
\def\theanswers{\theendnotes \medskip}


\begin{document}

    \ifprintanswers % prints out the answer key, based on \printanswers in the preamble
        \newpage
        \theanswers
    \else % prints out the exam itself

    \begin{questions}

        \qformat{\large \textbf{Question \thequestion:} \thequestiontitle\hfill(\thepoints)}


        \titledquestion{Syntax and Semantics}[30]
        \answer{Answer for Syntax and Semantics DONE}

        \titledquestion{Second Question}[30]
        \answer{Answer for Second Question \protect \thequestion DONE}

        \titledquestion{Third Question}[30] 
        \answer{Answer for Third Question \protect \thequestion DONE}
    \end{questions}
    \fi
\end{document}

相关内容