[Tex/LaTex] Is it possible to use the “lettrine” package with pandoc

lettrinepandoc

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?

Best Answer

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.