I want to typeset weekly exercise sheets for students. Typically, one sheet consists of 2-5 exercises. Additionallly, a version including solutions shall be provided for the tutors.
Since more or less the same exercises are given out each year, we want to create a collection of exercises which can then be put together in a custom order. So there shall be one main document with the preamble and everything, which then includes or inputs the exercises.
I'm quite happy with the KOMA-Script class scrartcl, the only thing i'd like to have is an automatic numbering for the exercises and the solutions.
An easy (yet maybe not elegant) way to have the exercises numbered as i wish is the following:
\documentclass{scrartcl}
\usepackage{titlesec}
\titleformat{\subsection}{\large\bfseries\sffamily}{}{0pt}{Exercise \thesubsection:\quad}
\newcommand{\exercise}[1]{\subsection{#1}}
\newcommand{\solution}[1]{\subsection{#1}}
\begin{document}
\setcounter{section}{1}\setcounter{subsection}{0}
\exercise{This is the Name of the first Exercise}
This is the problem given for the first Exercise.
\exercise{This is the Name of the second Exercise}
This is the problem given for the second Exercise.
\addtocounter{section}{1}\setcounter{subsection}{0}
\exercise{This is the Name of the third Exercise}
This is the problem given for the third Exercise.
\solution{This is the solution for the third exercis.}
However, it should be titled "Solution 2.1" and not "Exercise 2.2".
\end{document}
However, i still need another command for \solution
, which gives out "Solution X.Y: ...", where X.Y is just the numbering of the last exercise.
I know there are a lot of packages like exam, answers, etc. out there, but none did what i wanted yet (could be me, though). In the exercise package i couldn't include figures or minipages the usual way, which i really disliked.
By the way, i don't mind commenting in or out the solutions by hand for the different versions. However, if there's an automated version to only include exercises or exercises and solutions, all the better!
Does anyone have a nice solution for my problem?
Related: How to implement a verbatim or null environment using a boolean within \newcommand
exsheets
is a good alternativeacrotex bundle
by D.P. Story. I think it has the features you need.exsheets
package (which I personally prefer) there are a number of alternatives, see for example Comparing packages which facilitate typesetting exercises and solutions: exercise vs. answers vs. probsolnexsheets
;-)exsheets
package is indeed looking very good and i am currently giving it a try. The formatting with thexcoffins
method seems a bit complicated at first glance, but still the result looks good so far.