Markdown to PDF using Pandoc since Xetex expires

On my MacBook (OSX Mountain Lion), I used 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 the --xetex option in markdown2pdf -N -o ../../Desktop/pandoc_output.pdf --xetex --toc --template=mytemplate-headers-garamond_date.tex 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 choose --xetex and do this:

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

then I get the following:

 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?

+8
markdown latex pandoc xetex
source share
3 answers

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

+16
source share

The previous answers to this question have been useful to me since I installed pandoc a couple of years ago, but never Tex Live. Therefore, I had no idea if I installed it correctly, so the whole way helped me to understand that it works as follows:

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

This is the default installation location for the BasicTex installation that you download from the Pandoc installation page.

I also forgot about using pandoc -D Latex >my-latex-template.tex to create the template. After providing the .tex template instead of my .html one (which caused "you have no BEGIN {" error), I received .PDF: In other words, the default template worked.

Also, I inaccurately entered -t pdf (not shown above) to set the pdf format to the output format, but that was wrong. The output format is Latex, which is then converted to PDF. There is no need to specify the output format with the dash -t option.

I hope this entry of my minor stumbles helps someone.

+6
source share

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

0
source share

All Articles