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]

  d=30pt,% For title
  a=12pt% For author & date


    {\tfd The space between the lines of this long title is not enough!}
    {\tfa The author}
    {\tfa September 10, 2013}



  • Untested: Try {\bfd\setupinterlinespace ... \endgraf}, etc.
    – Aditya
    Sep 10, 2013 at 15:01
  • Also use a comma after a=12pt rather than a % (easier to add delete more options).
    – Aditya
    Sep 10, 2013 at 15:15
  • 1
    As far as I understand the OP does not want to modify the pandoc template, so the interline space setup has to be injected without altering the code. The following is a hack which works for the title, but might break in other places: \let\oldTFD\tfd\def\tfd{\oldTFD\setupinterlinespace\groupedcommand{}{\par}}
    – Marco
    Sep 10, 2013 at 16:53
  • 1
    @Marco: In this case, I think that it is relatively easy to modify the pandoc template. In fact, pandoc should be setting something like \setupvariables[metadata][title=...,author=...,date=...] and leave the formatting to a setup command in the preamble. I might just send a pull request to pandoc-templates, and then the OP wont have to change the template :)
    – Aditya
    Sep 10, 2013 at 17:07
  • 1
    @Aditya Fixing the pandoc template would be the best option, indeed. If you decide to send a fix upstream consider fixing descriptions as well, the default rendering is unusable (typeset the pandoc manual, then you'll know what I mean).
    – Marco
    Sep 10, 2013 at 17:33

1 Answer 1


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:

  {\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:


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.


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:

  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

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.


  • @Aditya Now that I understand how \setupinterlinespace works, I fully agree with this being a bug in the Pandoc template. Aditya, it would be great if you could also foresee [title],[author] and [date] "handles" in the Pandoc template pull request. This would make further manipulation of these objects a lot easier whilst leaving the remainder of the document untouched. Sep 11, 2013 at 8:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .