2

The following example gives a compile error:

   \documentclass{exam}
    \begin{document}
    \begin{questions}
    \section{Section 1}
    Some descriptive text.
    \question A really interesting question.
    \section{Section 2}
    \question Another really interesting question.     
    \end{questions}
    \end{document}

However, compilation works fine after moving "Some descriptive text." to after the first question.

How can I get this to compile and still have a properly indented section header and descriptive text? Note that if I didn't care about consistent section header/text indentation I could just move them to before "\begin{questions}".

This question is relevant, but not the same: How to use section in exam class.

2

You can insert a box with proper \leftskip:

\documentclass{exam}
\begin{document}
\section{Section 1}
Some descriptive text
\begin{questions}
  \section{Section 1}
  \vbox{\leftskip\leftmargin Some descriptive text.}
  \question A really interesting question.
  \section{Section 2}
  \question Another really interesting question.     
\end{questions}
\end{document}

enter image description here

  • Thanks, that definitely works (+1). It seems like a hack though -- if there's no "standard" way around it then maybe this is bug in the exam class. – Huck Bennett Mar 16 '18 at 21:11
  • I would not describe it as a bug, in section 6.1 of the manual you can see that he introduced \uplevel for your purpose. This command will lead to exactly one level of indention less than the current one which IMO does look better. So I think the problem is that you disagree with the author of the package about what "properly" indented means. You can still archive want you want with this hack, but it does look odd: It looks as if there is a number missing in front of the descriptive text. – Marcel Krüger Mar 16 '18 at 21:37

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.