Reputation: 41
I'm trying to prepare some exams in LaTeX, and am hoping to be able to have multi-part questions where some of the parts have their own preamble, which I'm having difficulty with.
As an example of how I'd like it to appear (dots just used to indent):
1) Here is some preable for the question that will apply throughout.
...a) Here is the first part of the question.
...Here is some further preamble that will apply for part b and part c.
...b) Here is the second part of the question.
...c) Here it the third part of the question.
...Here is some final preamble for the last part of the question.
...d) Here is the final part of the question.
I'm struggling to find a way to insert the preambles in. Currently I'm having to settle for inserting the preambles into the relevant following parts but this is less than ideal:
\documentclass{exam}
\begin{document}
\begin{questions}
\question
Here is some preamble for the question that will apply throughout.
\begin{parts}
\part
Here is the first part of the question.
\part
Here is some further preamble that will apply for part b and c. Here is the second part of the question.
\part
Here is the third part of the question.
\part
Here us some final preamble for the last part of the question. Here is the final part of the question.
\end{parts}
\end{questions}
\end{document}
I'm hoping there might be a way to effectively 'pause' the parts environment and return to the questions environment only - is there?
I do know that I can end parts and restart, manually overriding the starting part, but this feels like a total bodge and I thought there must be a better way.
Many thanks!
Upvotes: 1
Views: 1752
Reputation: 38977
You can use the \uplevel
macro or the EnvUplevel
environment to place instructions between the parts of your question:
\documentclass{exam}
\begin{document}
\begin{questions}
\question
Here is some preamble for the question that will apply throughout.
\begin{parts}
\part
Here is the first part of the question.
\uplevel{test}
\part
Here is some further preamble that will apply for part b and c. Here is the second part of the question.
\part
Here is the third part of the question.
\begin{EnvUplevel}
test
\end{EnvUplevel}
\part
Here us some final preamble for the last part of the question. Here is the final part of the question.
\end{parts}
\end{questions}
\end{document}
Upvotes: 2