I want to change the default strong emphasis command in the conversion from pandoc's markdown to LaTeX, say, from \textbf to \textsc. Since running pandoc in the source file prints into the .tex file \textbf, I think it has nothing to do with the chosen template (unless the latter redefines \textbf, but that doesn't seem like a good option). I wish to tell pandoc to convert its strong emphasis into a \strong LaTeX command that I can define in the LaTeX template.

  • 3
    This seems like a perfect case for a Pandoc filter or script (see: <johnmacfarlane.net/pandoc/scripting.html>). I think it should be relatively easy, but I'm too much of a Haskell noob to write it. I've posted a query to the Pandoc discussion list, and will post an answer here if one is forthcoming.
    – Paul M.
    Feb 16, 2012 at 16:02
  • @PaulM. I decided to try here first, just in case it was something simple... Thank you for posting in the pandoc discussion list, I saw that there's already an answer there, and it worked for me (despite a warning). Please, post that answer so I can vote it.
    – henrique
    Feb 16, 2012 at 17:14

2 Answers 2


A query on the Pandoc discussion list yielded a couple of nice responses, from Andrea Rossato and John MacFarlane (developer of Pandoc). Below I give John's answer. This assumes you have the Haskell Platform installed.

  1. Assume this is your Pandoc file, myexample.md

    A *simple* pandoc example with **strong emphasis**!
  2. The following Haskell program exploits Pandoc's scripting interface

    -- strongify.hs
    -- compile as 'ghc --make strongify.hs'
    import Text.Pandoc
    main = toJsonFilter makeItStrong
       where makeItStrong (Strong xs) = [latex "\\strong{"] ++ xs ++ [latex "}"]
             makeItStrong x           = [x]
             latex                    = RawInline "latex" 
  3. Compile the program:

    ghc --make strongify.hs
  4. You can then use the generated executable as so:

    pandoc -t json myexample.md | ./strongify | pandoc -f json -t latex
  5. The output of step 4 is:

    A \emph{simple} pandoc example with \strong{strong emphasis}!    

John MacFarlane makes the following point:

"...the advantage of this approach over postprocessing the output with sed or perl: "\textbf" in verbatim environments won't be touched."

  • For the sake of completeness, when using csquotes in the template, running pandoc -t json ... loses smart quotes and punctuation, so one must add the -S option.
    – henrique
    Feb 17, 2012 at 0:34

For the benefit of future discoverers of this thread, see https://stackoverflow.com/questions/19472828/unable-to-compile-haskell-program-couldnt-match-errors, in which John explains subsequent changes to pandoc causes strongify.hs to throw an error.

This works under

-- strongify.hs
-- compile as 'ghc --make strongify.hs'

import Text.Pandoc
import Text.Pandoc.JSON

main = toJSONFilter makeItStrong
   where makeItStrong (Strong xs) = [latex "\\strong{"] ++ xs ++ [latex "}"]
         makeItStrong x           = [x]
         latex                    = RawInline (Format "latex")

You must log in to answer this question.

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