这个问题源于两个问题-这里第一个问题由@Gonzalo 解决和此处的后续问题由@touhami 解决\printanswers
。现在,当我使用命令时,我得到了与后续问题相同的错误使用 tikzpicture 环境:
! Extra }, or forgotten \endgroup.
\endmulticols ->\par \if@boxedmulticols \egroup
\balance@columns \return@non...
l.24 \end{multicols}
?
我的 MWE之前已经工作过命令\printanswers
如下:
% !TeX TS-program=pdfLaTeX
\documentclass{exam}
\printanswers
\noprintanswers
\pointsinrightmargin
\bracketedpoints
\usepackage{tikz}
\usetikzlibrary{arrows, circuits.ee.IEC,positioning, decorations.markings}
\usepackage[american voltages, american currents, siunitx]{circuitikz}
\usepackage[labelfont=,textfont={it}]{caption}
\captionsetup[figure]{name=Fig.,font=footnotesize}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{adjustbox}
\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 graph shown in the Fig.~\ref{fig:Q1}, which of the following is NOT \textit{a tree} of this graph?
\begin{choices}
\begin{multichoices}
\choice
\adjustbox{valign=t}{%
\scalebox{0.5}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (C) to (B);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9)
to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35)
to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}
} %EOS
}% adjustbox
\choice
\adjustbox{valign=t}{%
\scalebox{0.5}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (A) to (C);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9)
to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35)
to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}
} %EOS
}% adjustbox
\end{multichoices}\par
\begin{multichoices}
\CorrectChoice
\adjustbox{valign=t}{%
\scalebox{0.5}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (A) to (B);
\draw (C) to (B);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9)
to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35)
to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}
} %EOS
}% adjustbox
\choice
\adjustbox{valign=t}{%
\scalebox{0.5}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (D) to (C);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9)
to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35)
to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}
} %EOS
}% adjustbox
\end{multichoices}
\end{choices}
\end{minipage}\hfill%
\begin{adjustbox}{minipage={0.30\linewidth},valign=t}
\centering%
\scalebox{0.68}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (A) to (B);
\draw (C) to (B);
\draw (D) to (C);
\draw (A) to (D);
\draw (A) to (C);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9) to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35) to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}} %EoS
\captionof{figure}{\label{fig:Q1}}
\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}}
\end{multichoices}
\end{choices}
\end{minipage}\hfill%
\begin{adjustbox}{minipage={0.30\linewidth},valign=t}
\centering%
\scalebox{0.68}{%
\begin{tikzpicture}[x=3.22cm,y=3.22cm]
\coordinate [label=above left:\textcolor{blue}{}] (O) at (1.0,1.0);
\coordinate [label=above right:\textcolor{blue}{}] (A) at (0.0,1.0);
\coordinate [label=below:\textcolor{blue}{}] (B) at (1.0,2.0);
\coordinate [label=below:\textcolor{blue}{}] (C) at (2.0,1.0);
\coordinate [label=above:\textcolor{blue}{}] (D) at (1.0,0.0);
\draw ($(D)+(0.0,0.0)$) node[circ]{} to [R, l=5<\ohm>] ($(O)+(0.0,0.0)$) node[circ]{}
to ($(O)+(0.2,0.0)$) to [V, l_=2<\volt>] (A) node[circ]{}
to [R, l=3<\ohm>, label/align=straight] (B)
to [R, l=4<\ohm>, label/align=straight] ($(C)+(0.0,0.0)$) node[circ]{}
to [R, l=2<\ohm>, label/align=straight] ($(D)+(0.0,0.0)$)
to [I, l=2<\ampere>, label/align=straight]($(A)+(0.0,0.0)$) node[circ]{} ;
\draw ($(B)+(0.0,0.0)$) node[circ]{} to ($(B)+(0.0,-0.2)$) to [cI, l=$i_x$] ($(O)+(0.0,0.0)$)
to [I, l=1<\ampere>] ($(C)+(-0.2,0.0)$) to ($(C)+(0.0,0.0)$);
\draw[-stealth] ($(O)+(-0.06,-0.06)$) to node[left]{$i_x$} ($(O)+(-0.06,-0.3)$);
\end{tikzpicture}} %EoS
\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}
\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}
\end{adjustbox}
\end{questions}
\end{document}
答案1
在新版本中,需要multichoices
像这样(重新)定义环境
\makeatletter
\newenvironment{multichoices}[1][2]{%
\begin{multicols}{#1}}{%
\if@correctchoice \color@endgroup \endgroup \fi
\end{multicols}}
\makeatother
平均能量损失
\documentclass{exam}
\printanswers
%\noprintanswers
\pointsinrightmargin
\bracketedpoints
\usepackage{tikz}
\usetikzlibrary{arrows, circuits.ee.IEC,positioning, decorations.markings}
\usepackage[american voltages, american currents, siunitx]{circuitikz}
\usepackage[labelfont=,textfont={it}]{caption}
\captionsetup[figure]{name=Fig.,font=footnotesize}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{adjustbox}
\makeatletter
\newenvironment{multichoices}[1][2]{%
\begin{multicols}{#1}}{%
\if@correctchoice \color@endgroup \endgroup \fi
\end{multicols}}
\makeatother
\begin{document}
\begin{questions}
\question
\begin{minipage}[t]{0.65\linewidth}
Consider the graph shown in the Fig.~\ref{fig:Q1}, which of the following is NOT \textit{a tree} of this graph?
\begin{choices}
\begin{multichoices}
\choice
\adjustbox{valign=t}{%
\scalebox{0.5}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (C) to (B);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9)
to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35)
to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}
} %EOS
}% adjustbox
\choice
\adjustbox{valign=t}{%
\scalebox{0.5}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (A) to (C);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9)
to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35)
to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}
} %EOS
}% adjustbox
\end{multichoices}\par
\begin{multichoices}
\CorrectChoice
\adjustbox{valign=t}{%
\scalebox{0.5}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (A) to (B);
\draw (C) to (B);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9)
to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35)
to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}
} %EOS
}% adjustbox
\choice
\adjustbox{valign=t}{%
\scalebox{0.5}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (D) to (C);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9)
to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35)
to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}
} %EOS
}% adjustbox
\end{multichoices}
\end{choices}
\end{minipage}\hfill%
\begin{adjustbox}{minipage={0.30\linewidth},valign=t}
\centering%
\scalebox{0.68}{%
\begin{tikzpicture}[anchor=center, x=4cm, y=4cm]
\coordinate [label=below left:\textcolor{blue}{}] (A) at (0.0,0.0);
\coordinate [label=above left:\textcolor{blue}{}] (B) at (0.0,0.8);
\coordinate [label=above right:\textcolor{blue}{}] (C) at (0.8,0.8);
\coordinate [label=below right:\textcolor{blue}{}] (D) at (0.8,0.0);
\draw (A) to (B);
\draw (C) to (B);
\draw (D) to (C);
\draw (A) to (D);
\draw (A) to (C);
\draw (D) to [bend right=55] (1.1,0.9) to (1.1,0.9) to [bend right=55] (B);
\draw (B) to [bend right=40] (-0.4,0.45) to (-0.4,0.35) to [bend right=40] (A);
\fill (B) circle(2pt);
\fill (D) circle(2pt);
\fill (A) circle(2pt);
\fill (C) circle(2pt);
\end{tikzpicture}} %EoS
\captionof{figure}{\label{fig:Q1}}
\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}}
\end{multichoices}
\end{choices}
\end{minipage}\hfill%
\begin{adjustbox}{minipage={0.30\linewidth},valign=t}
\centering%
\scalebox{0.68}{%
\begin{tikzpicture}[x=3.22cm,y=3.22cm]
\coordinate [label=above left:\textcolor{blue}{}] (O) at (1.0,1.0);
\coordinate [label=above right:\textcolor{blue}{}] (A) at (0.0,1.0);
\coordinate [label=below:\textcolor{blue}{}] (B) at (1.0,2.0);
\coordinate [label=below:\textcolor{blue}{}] (C) at (2.0,1.0);
\coordinate [label=above:\textcolor{blue}{}] (D) at (1.0,0.0);
\draw ($(D)+(0.0,0.0)$) node[circ]{} to [R, l=5<\ohm>] ($(O)+(0.0,0.0)$) node[circ]{}
to ($(O)+(0.2,0.0)$) to [V, l_=2<\volt>] (A) node[circ]{}
to [R, l=3<\ohm>, label/align=straight] (B)
to [R, l=4<\ohm>, label/align=straight] ($(C)+(0.0,0.0)$) node[circ]{}
to [R, l=2<\ohm>, label/align=straight] ($(D)+(0.0,0.0)$)
to [I, l=2<\ampere>, label/align=straight]($(A)+(0.0,0.0)$) node[circ]{} ;
\draw ($(B)+(0.0,0.0)$) node[circ]{} to ($(B)+(0.0,-0.2)$) to [cI, l=$i_x$] ($(O)+(0.0,0.0)$)
to [I, l=1<\ampere>] ($(C)+(-0.2,0.0)$) to ($(C)+(0.0,0.0)$);
\draw[-stealth] ($(O)+(-0.06,-0.06)$) to node[left]{$i_x$} ($(O)+(-0.06,-0.3)$);
\end{tikzpicture}} %EoS
\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}
\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}
\end{adjustbox}
\end{questions}
\end{document}