6

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:

enter image description here

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}

\SetupExSheets{headings=runin}
\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?
Moriambar
  • 11,466
jub0bs
  • 58,916

1 Answers1

7

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}

Original answer:

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.

enter image description here

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:
\DeclareInstance{exsheets-heading}{block-extended}{default}{
  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_heading_title_user_format_tl
    \tl_use:N \l_exsheets_question_title_extra_tl
  }
}
\ExplSyntaxOff

% use the new instance:
\SetupExSheets{headings=block-extended}

\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}
cgnieder
  • 66,645
  • The man himself! That's great! Would you consider adding that key to a future version of exsheets? – jub0bs Sep 27 '13 at 08: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... – cgnieder Sep 27 '13 at 08: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 08:42
  • @Jubobs I think that I'll release v0.10 in the next few days. It will contain a solution for adding subtitles (when a heading instance is chosen that supports it). – cgnieder Sep 27 '13 at 12:03
  • That's great. I'm sure it will be useful to other people as well. – jub0bs Sep 27 '13 at 15:15
  • Last-minute suggestion: what do you think of adding a key for indicative duration, i.e. the expected time that an average student would require to complete the exercise? – jub0bs Sep 29 '13 at 21:46
  • @Jubobs I'm not convinced: for one thing I think that this may put extra pressure on students and thus should be avoided in exams (could be helpful in exercises, though); more importantly I think there a various possibilities of adding such information already... (BTW: we shouldn't discuss feature requests in comments. But you can always email me...) – cgnieder Sep 29 '13 at 22:29
  • I agree with you about exams, but I think an indicative duration can be useful in labs/tutorials that consists in multiple exercises, because it gives students a licence to skip an exercise if they've been stuck on it for too long. Sorry for discussing feature requests here. I'll use email for future communication. – jub0bs Sep 29 '13 at 23:13
  • I've been trying to implement this solution but I keep getting an Undefined control sequence error on \begin{question}. Could it be babel? I'm using spanish. – han-tyumi May 16 '15 at 15:14
  • @Majoko the error message surely tells you which control sequence is undefined. This is important to know, otherwise everything's is pure guesswork – cgnieder May 16 '15 at 15:17
  • 1
    The full error is: [26] (./prob/econ_cerrada-problemas.tex ./prob/econ_cerrada-problemas.tex:1: Undefined control sequence. \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
  • 1
    @Majoko actually quite a while ago, see my updated answer – cgnieder May 16 '15 at 15:26