9

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?

Werner
  • 14,324
  • 7
  • 55
  • 77
incandescentman
  • 6,168
  • 3
  • 46
  • 86

3 Answers3

19

Try --latex-engine=xelatex instead of --xetex

Mohamed Ragab
  • 539
  • 3
  • 7
6

The prior answers to this question were helpful to me, as I had installed pandoc a couple years ago, but never Tex Live. Consequently I had no idea if I had installed it correctly, so putting in the entire path helped me to see that it was working, as follows:

pandoc --latex-engine=/usr/local/texlive/2012basic/bin/universal-darwin/xelatex

This is the default install location for the BasicTex setup which you download from the Pandoc install page.

I had also forgotten about using pandoc -D Latex >my-latex-template.tex to generate a template. After giving a .tex template instead of my .html one (which caused a 'you don't have BEGIN {' error) , I got .PDF: In other words, the default template worked.

Also, I had inaccurately entered -t pdf (not shown above) to set pdf as an output format, but this was not correct. The output format is Latex, which is then translated to PDF. It is not necessary to specify an output format with the dash -t option.

I hope this record of my minor stumbles saves someone some time.

George D Girton
  • 763
  • 10
  • 15
0

See the pandoc User's Guide (or man page) for the --latex-engine option.

John MacFarlane
  • 8,511
  • 39
  • 33