为问题添加标签或标记

为问题添加标签或标记

我正在制作关于物理不同章节的迷你问题库。为此,我使用“考试”类。我需要的是以下内容:

我想针对每个问题添加一些我自己使用的信息。例如,年份、难度级别(难、易等)、主题名称和此类标签。我需要能够根据情况打印或禁止打印这些标签。

以下是 MWE:

\documentclass[addpoints,answers,10pt]{exam}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{nonfloat}
\usepackage{caption}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{ifpdf}
\usepackage[export]{adjustbox}


\usepackage{graphicx}
\usepackage{background}


\unframedsolutions
\printanswers

\begin{document}
        \section{ABC}
    \begin{questions}

        \question This is question 1 ? 
        \begin{solution}
            This is answer 1
        \end{solution}

        \question This is question 2
        \begin{solution}
            This is answer 2
        \end{solution}
        \question This is Question 3
        \begin{solution}
            This is answer 3
        \end{solution}
\end{questions}
\end{document}

想要的是如下内容:

    \begin{document}
    \section{ABC}
    \begin{questions}

        \question This is question 1 ? \label{difficult, 2009, Light}
        \begin{solution}
            This is answer 1
        \end{solution}

        \question This is question 2 \label{moderate, 2019, Sound}
        \begin{solution}
            This is answer 2
        \end{solution}
        \question This is Question 3
        \begin{solution}
            This is answer 3
        \end{solution}
\end{questions}
\end{document}

而且当我们使用'\printanswers'时,我应该能够使用'\printlabels'或'\noprintlabels'

如何实现这一点?

答案1

像这样的事情??

\documentclass[addpoints,answers,10pt]{exam}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{nonfloat}
\usepackage{caption}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{ifpdf}
\usepackage[export]{adjustbox}


\usepackage{graphicx}
\usepackage{background}
\newcommand\printqtags{\def\qtag##1{\par\textbf{Tag: (##1)}}}
\newcommand\noprintqtags{\def\qtag##1{}}

\unframedsolutions
\printanswers
\printqtags
    \begin{document}
    \section{ABC}
    \begin{questions}

        \question This is question 1 ? \qtag{difficult, 2009, Light}
        \begin{solution}
            This is answer 1
        \end{solution}

        \question This is question 2 \qtag{moderate, 2019, Sound}
        \begin{solution}
            This is answer 2
        \end{solution}
        \question This is Question 3
        \begin{solution}
            This is answer 3
        \end{solution}
\end{questions}
\end{document}

在此处输入图片描述

改为\printqtags\noprintqtags结果变成

在此处输入图片描述

答案2

在 Steven B. Segletes 的帮助下,我可以累积每个问题针对不同标签的分数,请参阅下面的测试代码:

\documentclass[addpoints,answers,10pt]{exam}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{nonfloat}
\usepackage{caption}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{ifpdf}
\usepackage[export]{adjustbox}


\usepackage{graphicx}
\usepackage{background}
\newcommand\printqtags{\def\qtag##1{\par\textbf{Tag: (##1)}}}
\newcommand\noprintqtags{\def\qtag##1{}}

\newcounter{QTAGdifficult} 
\newcounter{QTAGmoderate}

\makeatletter
\newcommand\moderate{\addtocounter{QTAGmoderate}{\@points}moderate} 
\newcommand\difficult{\addtocounter{QTAGdifficult}{\@points}difficult}
\makeatother




\unframedsolutions
\printanswers
\printqtags
    \begin{document}
    \section{ABC}
    \begin{questions}

        \question[5] This is question 1 ? \qtag{\difficult, 2009, Light}
        \begin{solution}
            This is answer 1
        \end{solution}

        \question[5] This is question 2 \qtag{\moderate, 2019, Sound}
        \begin{solution}
            This is answer 2
        \end{solution}
        \question[6] This is Question 3 \qtag{\difficult, 2009, Light}
        \begin{solution}
            This is answer 3
        \end{solution}
\end{questions}

Moderate tags: \theQTAGmoderate 

Difficult tags: \theQTAGdifficult
\end{document}

这是结果 pdf 屏幕截图。

输出 pdf 的图片截图

顺便说一句:我不知道课堂上每道题是否有默认分值exam。例如,对于判断题,默认分值应该是 2 分,所以我不需要[2]在每个问题中都填写。编辑哦,我明白了,我找到了解决方案,如果问题没有指定分值,它将使用之前定义的上一个问题的分值。

相关内容