I am using a pandoc template to convert a markdown file to pdf via xelatex. I'd like to use the lettrine package to make the first letter of a paragraph big, but pandoc inserts the main markdown text using the $body$ variable. Is there a way to tell pandoc to render every first letter as a lettrine?

  • I think this is a pandoc issue, but i never really worked with pandoc. I think this is off-topic here. – Johannes_B Nov 5 '17 at 9:48
  • You'll need to add a step. I believe pandoc can at a custom header (preamble) to an output file, so if you can do it in the preamble it's doable. And that question would be on topic – Chris H Nov 5 '17 at 11:53
  • Related: tex.stackexchange.com/q/303718/28808 – Chris H Nov 8 '17 at 17:08

You can use the pandoc-lettrine filter. In your markdown document, simply mark the first character of a paragraph with square brackets, and include \usepackage{lettrine} in your metadata block. For example:

header-includes: \usepackage{lettrine}

[L]orem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sollicitudin dignissim ligula ac ultricies. Donec in dictum sapien. Suspendisse sed eros nec risus facilisis eleifend. In lorem metus, laoreet et quam at, accumsan blandit odio. Quisque porttitor porttitor massa, vitae ultrices turpis mattis quis. Sed eu cursus arcu, id pulvinar urna. Aliquam sit amet varius ipsum, non tincidunt sapien. Maecenas a pretium dui. Fusce porta lobortis suscipit.

Now invoke pandoc with a call to the filter:

pandoc demo.md -s --filter lettrine demo.tex

Output is available in TeX, pdf, and html formats.

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.