I'm working on a textbook with sections and subsections, where some subsections are dedicated to exercises.
\documentclass[12pt]{book}
\begin{document}
\section{First!}
\subsection{Some theorems}
Theorem I guess...
\subsection{Exercises}
\begin{enumerate}
\item How much is 1+1?
\item How much is 2+3?
\end{enumerate}
\section{Second!}
\subsection{Let's define something}
A natural number is a number different from a fraction.
\subsection{More theorems}
I like fractions.
\subsection{Exercises}
\begin{enumerate}
\item Is $\pi$ a natural number?
\item Do you like natural numbers?
\end{enumerate}
\end{document}
I would like to add the solutions in the code and have them gathered for a solutionfile. I know packages like answers
and exsheets
can do a good job, but I would like to keep the lay-out of the questions, while having one large solution-file, with automated numbering (in which it is clear which answer corresponds with which question).
Preferably something like
Keep in mind the number of exercises per subsection can be more then 10, so I'd like to keep my solutions (in code) close to the questions.
\@startsection {section}{1}{\z@}% {-3.5ex \@plus -1ex \@minus -.2ex}% {2.3ex \@plus.2ex}% {\normalfont\Large\bfseries}}
One can find a listing of \@startsection in source2e.pdf from CTAN. The arguments control the indentation, vertical spacing and font used. For a single paragraph, one can fake enumerate using\noindent\makebox[\labelwidth][r]{...}\hspace{\labelsep}\parbox{\dimexpr \textwidth-\labelwidth-\labelsep}{...}