latexmarkdownpandoctex

Define pandoc md to tex conversion rules?


Is it possible to define how headings are converted from Markdown to LaTeX?

I would like to convert

# Heading 1

to

\chapter{Heading 1}

and

## Heading 2

to

\section{Heading 2}

and so on.


Solution

  • There is an option now:

    pandoc --base-header-level=2
    

    Old answer:

    I think you'll have to write a pandoc filter that increments the heading integer by one, something along the lines of:

    #!/usr/bin/env runhaskell
    import Text.Pandoc.JSON
    
    main :: IO ()
    main = toJSONFilter inchead
      where inchead (Header n attr xs) = Header (n+1) attr xs
            inchead x = x