3

I'm using the excellent exsheets package to write the problem sections of a book. Because I need titles for the questions, I'm using the subtitle functionality built in the package. So even though it does the job, there are two problems:

  1. Subtitles don't have automatic line break.
  2. Subtitles with commas or accents produce errors.

Consider the following MWE:

\documentclass{article}

\usepackage[showframe]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{exsheets}
\SetupExSheets{
  headings = block-subtitle
}

\begin{document}

\begin{question}[subtitle=I'm trying to make a super long subtitle that extends way beyond the page's normal margins.]
First exercise.
\end{question}

\begin{question}[subtitle={Another subtitle, now with commas and áccents}]
Second exercise.
\end{question}
\end{document}

Problem no. 2 seems like the worst one. Loading inputenc with utf8 doesn't fix it, but I discovered that enclosing the subtitle in brackets works, like I did in the MWE. Nevertheless, can it be done without the brackets?

I haven't been able to fix problem no. 1. I've tried \newline, double backslash, etc. Any ideas on how could I fix it?

3

Options and commas

Since the optional argument to the question environment can be a comma separated list

[subtitle=Another subtitle, now with commas and áccents]

consists of two “options”:

  • subtitle=Another subtitle
  • now with commas and áccents

As you've found out yourself: if a option contains a comma, the argument must be placed in braces:

[subtitle={Another subtitle, now with commas and áccents}]

As far as the accent is concerned: that's a question of using the right input encoding. Using a unicode á and \usepackage[utf8]{inputenc} will work nicely with pdflatex.

Subtitles

Subtitles are typeset in a horizontal box. Consequences are: no line breaks. A possible workaround would be a suitable redefinition of the block-subtitle instance using the subtitle-pre-code option in order to place the subtitle within a \parbox. Since the code following the pre-code is wrapped in braces this will work:

\DeclareInstance{exsheets-heading}{block-subtitle}{default}{
  join = {
    title[r,B]number[l,B](.333em,0pt) ;
    title[r,B]subtitle[l,B](1em,0pt) ;
    title[l,B]points[l,B](\linewidth+\marginparsep,0pt) ;
    main[l,T]title[l,T](0pt,0pt) ;
  } ,
  subtitle-pre-code = \parbox[t]{.8\linewidth}
}

The complete code:

\documentclass{article}

\usepackage{showframe}
\usepackage[utf8]{inputenc}
\usepackage{exsheets}
\DeclareInstance{exsheets-heading}{block-subtitle}{default}{
  join = {
    title[r,B]number[l,B](.333em,0pt) ;
    title[r,B]subtitle[l,B](1em,0pt) ;
    title[l,B]points[l,B](\linewidth+\marginparsep,0pt) ;
    main[l,T]title[l,T](0pt,0pt) ;
  } ,
  subtitle-pre-code = \parbox[t]{.8\linewidth}
}
\SetupExSheets{
  headings = block-subtitle
}

\begin{document}

\begin{question}[subtitle={I'm trying to make a super long subtitle that
    extends way beyond the page's normal margins.}]
  First exercise. More text
\end{question}

\begin{question}[subtitle={Another subtitle, now with commas and áccents}]
  Second exercise.
\end{question}

\end{document}

enter image description here

  • Excellent! Placing subtitles in parbox could be the default implementation for future releases... or is there a disadvantage I don't see? – han-tyumi May 22 '15 at 14:36
  • There is one problem: knowing how much space is left to the end of the column in order to give a suitable width to the \parbox. It is solvable, though :) – clemens May 22 '15 at 14:39
  • Ah yes, I see it. In fact, in my book's current configuration the margin is a bit smaller than the one you set up on your solution. Anyway, nice work with exsheets! – han-tyumi May 22 '15 at 14:42
2

A dirty trick:

\documentclass{article}

\usepackage[showframe]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{exsheets}
\SetupExSheets{
  headings = block-subtitle
}

\begin{document}

\begin{question}[subtitle=\parbox[t][-1ex]{0.8\hsize}{%
                 I'm trying to make a super long subtitle that extends way beyond the page's normal margins.}]
\bigskip
First exercise.
\end{question}

\begin{question}[subtitle={Another subtitle, now with commas and áccents}]
Second exercise.
\end{question}
\end{document}

You need to compile at least twice that new formatting overtake the control. The width of \parbox you select according to your needs. enter image description here

1

Dirty trick for the 2nd problem (also compiled twice):

\documentclass{article}

\usepackage[showframe]{geometry}
\usepackage[utf8x]{inputenc}
\usepackage{exsheets}
\SetupExSheets{
  headings = block-subtitle
}


\begin{question}[subtitle=Another subtitle{,} now with commas and \'{a}ccents]
Second exercise.
\end{question}
\end{document}
  • 1
    Rather than placing the comma within braces you should surround the whole option with braces as the OP has done in his question. Then the outer set of braces will be removed when the option is processed whereas here the comma will stay in braces which may have effects on kerning... – clemens May 22 '15 at 14:29
  • I agree with @clemens. I think the reason why is nicely explained in his answer. – han-tyumi May 22 '15 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.