# Maintainable approach to adding a title to an exsheets question?

I've started using cgnieder's wonderful exsheets package for my problem sets, but it seems to be missing a valuable functionality: exercise titles. In my case, the latter would prove particularly useful because

• they can provide a concise (if somewhat cryptic) description of the exercise; and
• intriguing/cheeky titles can be effective at raising students' interest.

Ideally, an exercise with a title would look something like that:

However, exsheets doesn't seem to offer that title functionality out of the box: no title (or similar) key is defined for the question environment. My workaround so far is to

1. locally switch the headings option to runin,
2. typeset the exercise's title manually at the beginning of the question environment,
3. add a linebreak.

However, that approach is not very satisfying in terms of maintainability.

\documentclass{article}

\usepackage[english]{babel}
\usepackage{exsheets}
\usepackage{kantlipsum}

\begin{document}

\begin{question}
\textbf{Fermat's last theorem}\\
\kant[1]
\end{question}

\end{document}


I very much wish there were a title option. Before I start dissecting exhseets.sty with the hope of producing a solution...

• Am I missing something obvious in the documentation? Is it an RTFM case?
• If not, how can I create a title key for the exsheets' question environment that would do the job?
• You will get paid for doing this, right? :-) – kiss my armpit Sep 27 '13 at 3:42

Edit 2015/05/16:

exsheets questions have a subtitle option (since v0.10, 2013/10/11). In order to use it one needs to activate a headings instance which uses subtitles:

\documentclass{article}

\usepackage{exsheets}
\SetupExSheets{
headings = block-subtitle ,
subtitle-format = \bfseries % default is \itshape
}
\usepackage{kantlipsum}

\begin{document}

\begin{question}[subtitle=Fermat's last theorem]
\kant[1]
\end{question}

\begin{question}
\kant[2]
\end{question}

\begin{question}[subtitle=L'H\^opital's rule]
\kant[3]
\end{question}

\end{document}


You can use two things:

1. exsheets headings are defined with the help of the xtemplate package. They have lot's of hooks that can be used to customize them. Here you'll want the number-post-code hook.
2. The options of the question environments are set in the module exsheets/question with l3keys. New options are easily added.

Here's the complete code for an example. I tried adding comments explaining what's going on:

\documentclass{article}

\usepackage[english]{babel}
\usepackage{exsheets}

\ExplSyntaxOn
% new tokenlist variable:
\tl_new:N \l_exsheets_question_title_extra_tl

% new key that sets this variable:
\keys_define:nn { exsheets / question }
{ title .tl_set:N = \l_exsheets_question_title_extra_tl }

% extend the block' instance to place the extra title part
% after the title number; we use the hook number-post-code
% for this:
join = { title[r,B]number[l,B](1ex,0pt) } ,
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
} ,
number-post-code = {
\tl_use:N \c_space_tl
\tl_use:N \l_exsheets_question_title_extra_tl
}
}
\ExplSyntaxOff

% use the new instance:

\usepackage{kantlipsum}

\begin{document}

\begin{question}[title=Fermat's last theorem]
\kant[1]
\end{question}

\begin{question}
\kant[2]
\end{question}

\begin{question}[title=L'H\^opital's rule]
\kant[3]
\end{question}

\end{document}

• The man himself! That's great! Would you consider adding that key to a future version of exsheets? – jub0bs Sep 27 '13 at 8:28
• @Jubobs I might :) One thing to solve remains: if solutions are added they won't pick up the extra title part with the solution above... – clemens Sep 27 '13 at 8:39
• Yes, I noticed that. That might be a valuable addition, but I personally only need titles for the questions: by choosing intriguing/cheeky titles, I'm hoping to raise student's interest in them. Thanks again for your answer and for exsheets`! – jub0bs Sep 27 '13 at 8:42
• The full error is: [26] (./prob/econ_cerrada-problemas.tex ./prob/econ_cerrada-problemas.tex:1: Undefined control sequence. <argument> \LaTeX3 error: Erroneous variable \l__exsheets_heading_title_use... l.1 \begin{question} But I have realized you now have implemented an "official" way of adding subtitles... – han-tyumi May 16 '15 at 15:19
• @Majoko actually quite a while ago, see my updated answer – clemens May 16 '15 at 15:26