3

This question has been derieved from two questions- the first question here solved by @Gonzalo and the follow up question here solved by @touhami. Now, I get the same error that of the follow up question when I use \printanswers command with tikzpicture environment:

! Extra }, or forgotten \endgroup.
\endmulticols ->\par \if@boxedmulticols \egroup 
                                                \balance@columns \return@non...
l.24             \end{multicols}

?

my MWE which was working earlier with \printanswers command is given below:

% !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}

The output after running the above code with \noprintanswers command is here

  • The code you post does not produce an error on my TeXLive 2018 distribution. What has one to do to get the error message? – user121799 Sep 26 '18 at 3:48
  • 1
    @marmot there is an error when \noprintanswers is commented – touhami Sep 26 '18 at 6:36
  • @JLeonV. there is an error when \noprintanswers is commented – touhami Sep 26 '18 at 6:37
4

With he new version, one need to (re)define the environment multichoices like this

\makeatletter
\newenvironment{multichoices}[1][2]{%
\begin{multicols}{#1}}{%
\if@correctchoice  \color@endgroup \endgroup \fi
\end{multicols}}
\makeatother

MWE

\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}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.