I am typesetting exercises with the exercise package. I want to have my custom exercise header, my custom answer header as well as the exercise and answer body all left aligned. It works well for the answer environment, but not really for the exercise part.


        Aufgabe \ExerciseHeaderNB} (\ExerciseHeaderTitle)
\renewcommand{\AnswerHeader}{\flushright \textbf{\textsf{Lösung
            \ExerciseHeaderNB}         }\ExerciseHeaderOrigin\smallskip\newline}



\begin{Exercise}[label = wdsw, title = Widerstandswürfel , difficulty =      2]
Gegeben ist ein Würfel, wobei jede der Kanten einen Widerstand von $R = 1~\mathrm{\Omega}$ hat.\\
Wie groß ist der Widerstand entlang einer Raumdiagonale?
Wir wollen den Widerstand zwischen den Punkten $X$ und $Y$ bestimmen,   also entlang der Raumdiagonale (siehe Abb. \ref{fig:wdsws1}). Weil die Raumdiagonale eine Symmetrieachse ist, sollte das Problem symmetrisch sein, und deswegen eine recht einfache Lösung haben.\\

There are two parts to this answer:

  • After redefining the macros \ExerciseHeader and \AnswerHeader, the indentation of the the headlines equals the usual indentation of the text. You can set this to zero with:

  • In the code of the exercise package, there is a hard-coded \hspace{.66em} at the start of the Exercise body. To neutralize it, you can redefine \AtBeginExercise:


So your full header section on the style of the Exercise and Answer could look like this:



\renewcommand{\ExerciseHeader}{\large\textbf{\ExerciseName~\ExerciseHeaderNB} (\ExerciseTitle)\smallskip\newline}



enter image description here

Update: You might be right, there is still too much space before the exercise title, and I'm not one hundred percent sure about the space in front of the exercise body. So with changing "Aufgabe" to "Hausaufgabe" and "Gegeben ist ein Würfel" to "Es ist ein Würfel gegeben" (to have straigth lines at the left to compare indentation more easily), I find this configuration satisfying to my eye:



\renewcommand{\ExerciseHeader}{\AtBeginExerciseHeader\large\textbf{\ExerciseName~\ExerciseHeaderNB} (\ExerciseTitle)\newline}



enter image description here

  • Thanks. That really solves nearly everything. I don't want to nitpick, but there is still a (very small, I didn't realise it at first) misalignment of the first line of the exercise body and the title of the the exercise ("Gegeben" is a bit off to the right). Is there a way to remove this, or to adjust the answer environment? – Razupaltuff May 15 '17 at 10:00
  • You can of course play with the definition of \AtBeginExercise. I first had it at -7pt, maybe that is a good starting point for you. Similarly, you could define a \AtBeginExerciseHeader, insert it at the beginning of the redefinition of \ExerciseHeader and start trying like -1pt there. Just change in small steps until you (and the cangaroo ;) ) are satisfied. – Tiuri May 15 '17 at 10:46

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.