[Tex/LaTex] ConTeXt: How to increase line-spacing in title

contextcontext-mkivline-spacingpandoctitles

Pandoc generates ConTeXT document titles using a standard simple scheme that sets the title in \tfd. I already changed the default font and size of \tfd. However, when a title is so long that it occupies more than one line, standard line-spacing turns out to be inadequate.

In below example, the "p" of "space" and the "l" of "long" are almost touching. Compare this with the "p" and "l" of the normal text below.

Question: How do I obtain a larger line-spacing by only modifying the preamble (i.e. not changing anything between \starttext and \stoptext)?

\setuptolerance[horizontal, tolerant, stretch]

\usetypescript[pagella]
\setupbodyfont[pagella,12pt]
\setupbodyfontenvironment[12pt][
  d=30pt,% For title
  a=12pt% For author & date
  ]

\setuppagenumbering[location={footer,center}]

\starttext
\startalignment[center]
  \blank[2*big]
    {\tfd The space between the lines of this long title is not enough!}
  \blank[3*medium]
    {\tfa The author}
  \blank[2*medium]
    {\tfa September 10, 2013}
  \blank[3*medium]
\stopalignment

Space,\crlf
please!
\stoptext

output

Best Answer

The fix

As Aditya already pointed out, this is a bug in the pandoc ConTeXt template and should be fixed upstream. For the mean time the best you can do is to edit the template and change the title setup to:

[…]
\startalignment[center]
  \blank[2*big]
  {\tfd\setupinterlinespace $title$\par}
[…]

This custom template can then be used using the --template switch.

pandoc --to=context --template=mytemplate.context input.md

A better solution would be to store the document metadata once and use ConTeXt macros. This would semantically be a better markup conversion from Markdown to ConTeXt. Furthermore, it simplifies the resulting code when the data is used, for example on the title page and the PDF meta data in \setupinteraction.

If you neither want to create a custom template nor wait for an upstream fix, here's an ugly hack:

\let\oldTFD\tfd
\def\tfd
  {\oldTFD\setupinterlinespace\groupedcommand{}{\par}}

This redefines the \tfd font switch to automatically adjust the interline space and finish the paragraph (see \groupedcommand). However, this changes the behaviour of the low-level \tfd command and thus might break something else.

Reason

The reason the interline space is wrong is because the font is switched using a rather low-level font command which does not adjust the interline spacing. Another reason is that the line is not a paragraph and the line spacing adjustment operates on a paragraph. Compare:

\starttext
  foo\par {\tfd Bar}                          \par
  foo\par {\tfd Bar\par}                      \par
  foo\par {\tfd\setupinterlinespace Bar}      \par
  foo\par {\tfd\setupinterlinespace Bar\par}  \par %% correct spacing

  foo\par {\switchtobodyfont[24pt]Bar}        \par
  foo\par {\switchtobodyfont[24pt]Bar\par}    \par %% correct spacing
\stoptext

As you can see \tfd requires setting the interline space as well as a \par. The higher level font switch command \switchtobodyfont takes care of the interline spacing. But both of them require a \par.

result

Related Question