Multicols 环境在练习环境中无法正常工作

Multicols 环境在练习环境中无法正常工作

multicols我在练习环境中使用环境时遇到问题。这是我的 MWE:

\documentclass[11pt]{exam}

\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{ifthen}
\newboolean{firstanswerofthechapter}  
\usepackage{stackengine}
\usepackage{tasks}
\newlength{\longestlabel}
\settowidth{\longestlabel}{\bfseries\sffamily vv}
\settasks{after-item-skip=3pt,%gap for next row
        before-skip=2pt,%gap from the text above    
          after-skip=0pt,%gap for next question
          label-width=20pt,%width from left
          item-indent=25pt,%indent from left
          label=$\EgyptianBlue\bm{(\alph*)}$,
          column-sep=0em, label-align=left}

\usepackage[lastexercise,answerdelayed]{exercise}




\begin{document}

\setcounter{Exercise}{0}

\begin{Exercise}



\Question
\Question
\Question










\end{Exercise}
    
\begin{Answer}



\Question $(a)$

\begin{multicols}{4}
\Question $(a)$
\Question $(a)$
\Question $(a)$
\Question $(a)$
\end{multicols}


\end{Answer}
\setboolean{firstanswerofthechapter}{false}
\shipoutAnswer

\end{document}

Answer如果我以 启动环境,代码中没有问题\Question,但是,如果我以 环境 启动(之前\multicols没有任何),则会出现以下错误:\Question\multicols

Extra }, or forgotten \endgroup.
\endmulticols ...le@items \color@endgroup \egroup 
                                                  \balance@columns \return@n...
l.60 \end{multicols}

我需要Answer以 开始环境\multicols。我还希望答案从左到右输入,例如

   1.     2.      3.       4.
   5.     6.      7.       8.

请帮忙。

答案1

文档的“4 已知问题”部分讨论了此问题。您可以在环境结束前exercise添加以下内容来避免错误:\EndCurrentQuestionmulticols

\documentclass[11pt]{exam}

\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{ifthen}
\newboolean{firstanswerofthechapter}  
\usepackage{stackengine}
\usepackage{tasks}
\newlength{\longestlabel}
\settowidth{\longestlabel}{\bfseries\sffamily vv}
\settasks{after-item-skip=3pt,%gap for next row
        before-skip=2pt,%gap from the text above    
          after-skip=0pt,%gap for next question
          label-width=20pt,%width from left
          item-indent=25pt,%indent from left
          label=$\EgyptianBlue\bm{(\alph*)}$,
          column-sep=0em, label-align=left}

\usepackage[lastexercise,answerdelayed]{exercise}




\begin{document}

\setcounter{Exercise}{0}

\begin{Exercise}



\Question
\Question
\Question










\end{Exercise}
    
\begin{Answer}


\begin{multicols}{4}
\Question $(a)$
\Question $(a)$
\Question $(a)$
\Question $(a)$
\EndCurrentQuestion
\end{multicols}


\end{Answer}
\setboolean{firstanswerofthechapter}{false}
\shipoutAnswer

\end{document}

相关内容