这个问题已从这个问题有附加功能。但是,当我使用\printanswers
命令时,代码给出了以下错误:
! Extra }, or forgotten \endgroup.
\endmulticols ->\par \if@boxedmulticols \egroup
\balance@columns \return@non...
l.24 \end{multicols}
?
我的 MWE 代码根据以下建议进行了修改贡萨洛·梅迪纳与之一起使用时\noprintanswers
如下所示:
\documentclass{exam}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{adjustbox}
%\printanswers
\noprintanswers
\begin{document}
\begin{questions}
\question
\begin{minipage}[t]{0.65\linewidth}
Consider the network graph shown in the figure, which of the following is NOT a \textit{tree} of this graph?
\begin{choices}
\begin{multicols}{2}
\choice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-a}}
\choice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-b}}
\end{multicols}\par
\begin{multicols}{2}
\choice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-c}}
\CorrectChoice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-a}}
\end{multicols}
\end{choices}
\end{minipage}\hfill%
\begin{adjustbox}{minipage={0.30\linewidth},valign=t}
\includegraphics[width=\linewidth]{example-image-a}
\end{adjustbox}
\end{questions}
\end{document}
当\printanswers
使用命令时,它应该给出如下输出,突出显示partlabel
与以下内容相对应的内容\CorrectChoice
:
\printanswer
有任何建议可以解决在给定代码中使用命令时出现的错误!
答案1
更新在这个解决方案中,我们定义了multichoices
像多列一样工作的新环境,默认情况下它有两列,但如果需要可以设置更多列。
\makeatletter
\newenvironment{multichoices}[1][2]{%
\begin{multicols}{#1}}{%
\if@correctchoice \endgroup \fi
\end{multicols}}
\makeatother
平均能量损失
\documentclass{exam}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{adjustbox}
\printanswers
%\noprintanswers
\makeatletter
\newenvironment{multichoices}[1][2]{%
\begin{multicols}{#1}}{%
\if@correctchoice \endgroup \fi
\end{multicols}}
\makeatother
\begin{document}
\begin{questions}
\question
\begin{minipage}[t]{0.65\linewidth}
Consider the network graph shown in the figure, which of the following is NOT a \textit{tree} of this graph?
\begin{choices}
\begin{multichoices}
\choice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-a}}
\choice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-b}}
\end{multichoices}\par
\begin{multichoices}
\CorrectChoice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-a}}
\choice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-c}}
\end{multichoices}
\end{choices}
\end{minipage}\hfill%
\begin{adjustbox}{minipage={0.30\linewidth},valign=t}
\includegraphics[width=\linewidth]{example-image-a}
\end{adjustbox}
\question
\begin{minipage}[t]{0.65\linewidth}
Consider the network graph shown in the figure, which of the following is NOT a \textit{tree} of this graph?
\begin{choices}
\begin{multichoices}
\choice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-a}}
\choice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-b}}
\end{multichoices}\par
\begin{multichoices}
\choice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-c}}
\CorrectChoice
\adjustbox{valign=t}{\includegraphics[scale=0.2]{example-image-a}}
\end{multichoices}
\end{choices}
\end{minipage}\hfill%
\begin{adjustbox}{minipage={0.30\linewidth},valign=t}
\includegraphics[width=\linewidth]{example-image-a}
\end{adjustbox}
\question
\begin{minipage}[t]{0.65\linewidth}
Consider the network graph shown in the figure, which of the following is NOT a \textit{tree} of this graph?
\begin{choices}
\begin{multichoices}
\choice
bla bla
\choice
bla bla
\end{multichoices}\par
\begin{multichoices}
\choice
bla bla
\CorrectChoice
bla bla
\end{multichoices}
\end{choices}
\end{minipage}\hfill%
\begin{adjustbox}{minipage={0.30\linewidth},valign=t}
\includegraphics[width=\linewidth]{example-image-a}
\end{adjustbox}
\question
\begin{minipage}[t]{0.65\linewidth}
Consider the network graph shown in the figure, which of the following is NOT a \textit{tree} of this graph?
\begin{choices}
\begin{multichoices}
\choice
bla bla
\choice
bla bla
\end{multichoices}\par
\begin{multichoices}
\CorrectChoice
bla bla
\choice
bla bla
\end{multichoices}
\end{choices}
\end{minipage}\hfill%
\begin{adjustbox}{minipage={0.30\linewidth},valign=t}
\includegraphics[width=\linewidth]{example-image-a}
\end{adjustbox}
\end{questions}
\end{document}