0

I am not longer able to use a self defined environment which depends on \printanswers before the first question since the exam class was updated to version 2.6. (I use this solution.)

With the exam class 2.5 I was able to do

\documentclass{exam}
\usepackage{framed}

\newenvironment{note}{%
    \ifprintanswers
        \begin{framed}\noindent\textbf{Note:}\par\noindent
    \else
        \setbox0\vbox\bgroup
    \fi
}{%
    \ifprintanswers
        \end{framed}%
    \else
        \egroup
    \fi%
}

\printanswers
%\noprintanswers

\begin{document}
\begin{questions}
\begin{note}
    this is a note
\end{note}
\question
question
\begin{solution}
    this is the solution
\end{solution}
\begin{note}
    this is another note
\end{note}
\end{questions}
\end{document}

But with the exam class 2.6 I always get this error:

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.25 \end{note}

1 Answer 1

1

The solution was to move the first note environment out of the question environment. An alternative solution using the comment package resulted in the same error as mentioned above.

\documentclass{exam}
\usepackage{framed}

\newenvironment{note}{%
    \ifprintanswers
        \begin{framed}\noindent\textbf{Note:}\par\noindent
    \else
        \setbox0\vbox\bgroup
    \fi
}{%
    \ifprintanswers
        \end{framed}%
    \else
        \egroup
    \fi%
}

\printanswers
%\noprintanswers

\begin{document}
\begin{note}
    this is a note
\end{note}
\begin{questions}
\question
question
\begin{solution}
    this is the solution
\end{solution}
\begin{note}
    this is another note
\end{note}
\end{questions}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .