As mentioned in the comments the exsheets
package can be used for this. The titles/names of the exercises can be given as a subtitle using the question
environment's subtitle
option. To actually print the subtitles a headings instance must be used that typesets it. The predefined block-subtitle
instance nearly looks the same as your own defined headings so it can be used.
This means we set
\SetupExSheets{
headings = block-subtitle ,
headings-format = \large\bfseries\sffamily ,
% needs v0.16 2014/09/14 to work:
subtitle-format = \large\bfseries\sffamily
}
which mimics the definitions in your question.
Next thing we need is obviously some mainquestion
counter which can be used to print the question numbers as 1.1, 1.2, 2.1, etc. Like you I use the section
counter for the task. Then we need
\SetupExSheets{
counter-within = section ,
counter-format = se.qu\IfQuestionSubtitleT{:} ,
}
\IfQuestionSubtitleT{:}
ensures that the colon only is typeset when a subtitle is given.
For managing the exercises they can be defined in an external file, myexercises.tex
, say. For the example below I saved it with the following contents:
\begin{question}[subtitle=This is the Name of the first Exercise,ID=Q1]
This is the problem given for the first Exercise.
\end{question}
\begin{solution}
This is the first solution.
\end{solution}
\begin{question}[subtitle=This is the Name of the second Exercise,ID=Q2]
This is the problem given for the second Exercise.
\end{question}
\begin{solution}
This is the second solution.
\end{solution}
\begin{question}[subtitle=This is the Name of the third Exercise,ID=Q3]
This is the problem given for the third Exercise.
\end{question}
\begin{solution}
This is the third solution.
\end{solution}
If we put everything together we get:
\documentclass{scrartcl}
\usepackage{exsheets}[2014/09/14] % v0.16 or newer
\SetupExSheets{
headings = block-subtitle ,
headings-format = \large\bfseries\sffamily ,
subtitle-format = \large\bfseries\sffamily ,
counter-within = section ,
counter-format = se.qu\IfQuestionSubtitleT{:} ,
% solution/print = true % uncomment for tutors
}
% needed in earlier versions of exsheets:
% \DeclareInstance{exsheets-heading}{block-subtitle}{default}{
% subtitle-format = \large\bfseries\sffamily ,
% join = {
% title[r,B]number[l,B](.333em,0pt) ;
% title[r,B]subtitle[l,B](1em,0pt)
% } ,
% attach = {
% main[l,vc]title[l,vc](0pt,0pt) ;
% main[r,vc]points[l,vc](\marginparsep,0pt)
% }
% }
\begin{document}
\stepcounter{section}
\includequestions[IDs={Q1,Q2}]{myexercises}
\stepcounter{section}
\includequestions[IDs=Q3]{myexercises}
\end{document}
If you uncomment the line
% solution/print = true
in the above example you'll get
If you instead add \printsolutions
at the end you'll get
Unfortunately there's currently no way to add subtitles to solutions.
Best Answer
I produced a format, as given in your question. Obviously, one can gussie-up the definitions to achieve a more aesthetically pleasing format. EDITED to give usage syntax desired by questioner.