latexmarkdownpandocxetex

Markdown to PDF using Pandoc since Xetex Deprecation


On my MacBook (OSX Mountain Lion), I used to use this Pandoc command to convert Markdown to PDF:

$ markdown2pdf -N -o pandoc_output.pdf  --xetex --toc --template=mytemplate.tex myfile.md

But markdown2pdf no longer works, and --xetex option in markdown2pdf -N -o ../../Desktop/pandoc_output.pdf --xetex --toc --template=mytemplate-headers-garamond_date.tex is deprecated.

If I do this:

$ pandoc -N -o Desktop/pandoc_output.pdf  --xetex --toc --template=mytemplate.tex myfile.md

I get this:

pandoc: unrecognized option `--xetex'

But if I take out --xetex and do this:

$ pandoc -N -o Desktop/pandoc_output.pdf  --toc --template=mytemplate.tex myfile.md

then I get this:

pandoc: Error producing PDF from TeX source.
! Package hyperref Error: Wrong driver option `xetex',
(hyperref)                because XeTeX is not detected.

See the hyperref package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.3925 \ProcessKeyvalOptions{Hyp}

What's the solution?


Solution

  • Try --pdf-engine=xelatex instead of --xetex.

    Prior to Pandoc 2.0, released in 2017, this option was called --latex-engine. If you have a very old version of Pandoc (check with pandoc --version), you may need to use this option instead.