我正在按照以下格式撰写多项选择题试卷
\documentclass{exam}
\begin{document}
\begin{questions}
\question This is a multiple choice question
\begin{choices}
\choice this is a choice
\choice this is another choice
\CorrectChoice this is the correct choice
\choice this is another choice
\end{choices}
\end{questions}
\end{document}
我想要在表格中文档末尾显示键,但无法实现。请帮忙。
答案1
我在课程手册中没有找到任何方法来实现这一点exam
,所以我做了一个快速的自定义解决方案,可以自动打印答案列表。你唯一需要做的就是使用\CC
来选择正确的选项,然后输入\printmyanswers
以列表形式显示答案。这个网站上有一些表格示例,但它非常冗长,我不确定它是否值得。
我把答案放在同一页,但您可以简单地\newpage
在命令前添加一个,例如。
输出
代码
\documentclass{exam}
\usepackage{pgffor}
\newcounter{solcount}
\setcounter{solcount}{1}
\newcommand\CC{%
\CorrectChoice\label{sol:\arabic{solcount}}
\stepcounter{solcount}
}
\newcommand\printmyanswers{%
\section*{\centering Answers Sheet}
\foreach \x in {1,...,\thequestion}{%
\noindent
\x.~\ref{sol:\x}\par
}
}
\begin{document}\noindent
\begin{questions}
\question This is a multiple choice question
\begin{choices}
\choice this is a choice
\choice this is another choice
\CC this is the correct choice
\choice this is another choice
\end{choices}
\question This is a multiple choice question
\begin{choices}
\choice this is a choice
\CC this is the correct choice
\choice this is another choice
\choice this is another choice
\end{choices}
\end{questions}
\printmyanswers
\end{document}
答案2
删除粗体正确选项
\CorrectChoiceEmphasis{}
打印答案时删除加粗的答案。更多信息可以在这里找到:http://mirrors.ctan.org/macros/latex/contrib/exam/examdoc.pdf
表格答案
\usepackage{xintexpr}
\usepackage[table]{xcolor} % loads also »colortbl«
\usepackage{color, colortbl}
\usepackage{pgffor}
\newcommand\CC{%
\CorrectChoice\label{sol:\thequestion}
}
\newcommand{\AnswerKeyCols}{10}
\newcommand{\AnswerKeyRows}{\xinttheexpr ceil(\thequestion / \AnswerKeyCols)\relax}
\newcommand\printmyanswers{%
\section*{\centering Answers Sheet}
\edef\rowSeq {\xintSeq{0}{\AnswerKeyRows-1}}
\edef\colSeq {\xintSeq{1}{\AnswerKeyCols}}
\begin{center}
\begin{tabular}{|*{\AnswerKeyCols}{c|}}
\hline
\xintFor* ##1 in {\rowSeq} \do {%
\xintFor* ##2 in {\colSeq} \do {\xintifForFirst{}{&}\cellcolor{gray}##2}\\
\hline
\xintFor* ##3 in {\colSeq} \do {\xintifForFirst{}{&}\xintifboolexpr{##1*\AnswerKeyCols + ##3 <= \thequestion}{~\ref{sol:##3}}{}}\\
\hline
}
\end{tabular}
\end{center}
}