Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
This seems like a perfect case for a Pandoc filter or script (see: <>). 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 '12 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 '12 at 17:14

2 Answers 2

up vote 5 down vote accepted

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,

    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 | ./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."

share|improve this answer
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 '12 at 0:34

For the benefit of future discoverers of this thread, see, 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")
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.