I have started using pandoc to auto-generate PDFs from my .md-notes. This is working out so far, I succeeded to customize the font, background etc. For readability, I want all the italic parts as well as all the bold parts in my document to be highlighted with a different color. I am using a latex template to format the produced pdf, but I don't know how to autocolor italic or bold parts. The same goes for sections or subsections.

If someone could point me in the right direction, I would be very grateful. Thanks a bunch and goodbye!

2 Answers 2


Pandoc uses \emph for emphasized text and \textbf for strongly emphasized text. You can include the code in your template or redefine the commands in a YAML header-includes section:

  - \let\emphasized\emph
  - \let\strong\textbf
  - \renewcommand{\emph}[1]{\textcolor{red}{\emphasized{#1}}}
  - \renewcommand{\textbf}[1]{\textcolor{blue}{\strong{#1}}}

The following will be *red*.

Strong will be **blue**.

The Overleaf docs on colours can serve as a good introduction.


It seems there are multiple ways to solve this, the comment suggested above works well.

What also works is:

\setmainfont{DejaVu Sans}[

This did the trick for me. I went with this option as I wanted to change the font as well.

  • This works, but every time I use bold or italic and go back to normal, the color goes back to black for the rest of the paragraph instead of the white I chose for the whole thing. That is kinda weird and I don't know why it happens. If I declare a default color, it works my section headings instead become white which they shouldn't. So I either have to explicitly change colors on sections or set the default font color for normal text which I don't know how to do since I can't find the documenation on \setmainfont
    – Enemoy
    Commented Jul 17, 2022 at 13:32

You must log in to answer this question.

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