Please correct my code as necessary. It is not compiling due to
! Package exercise Error: You don't respect the hierarchy of questions.
See the exercise package documentation for explanation.
Type H <return> for immediate help.
...
l.13 \begin{Question}W
hat is the symbol for copper?\end{Question}
?
The code is as follows:
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage{mhchem}
\usepackage[lastexercise]{exercise}
\begin{document}
\section{Naming of Chemical Compounds - A ``DIY'' Tutorial}
\begin{Exercise}[title=DIY]\end{Exercise}
\begin{ExePart}Question 1\end{ExePart}
\begin{Question}What is the symbol for copper?\end{Question}
\begin{Answer}\ce{Cu}\end{Answer}
\end{document}
It could be that I've missed something but the documentation does not even provide an example of the package's usage.
Best Answer
I managed to get it to work using the ExerciseList environment:
Use of \ExePart or redefinition of \QuestionNB
That said, you shouldn't need the
\ExePart
just to print "Question 1". It might be better to redefine\QuestionNB
instead, like this:Theorically, that should do what you want to achieve, although in practice, it's kind of a mess. I feel the reason is that the label is hardcoded in the package, and without a variable. This can however be "fixed" by resetting
\QuestionIndent
:So your example becomes:
which works for me (although I would personally find it nicer to put questions on the next line -- note: I'm not using the
mhchem
package):After playing a bit with more Questions/Answers, I do think it's missing a linebreak somewhere:
I'm also not very sure of the spacing: answers end up being closer to the next question than to the question they relate to...
Exercise title
In fact, it seems the problem with the linebreak comes from the fact that you're using
\Exercise[title=DIY]
instead of simply\Exercise{DIY}
, which defines the exercise name. When I change this:I get a linebreak:
and it is not necessary anymore to redefine
\QuestionIndent
: