Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 201
incandescentman Avatar asked Nov 04 '12 00:11

incandescentman


People also ask

Can Pandoc convert from PDF?

You can't. You can try opening the PDF in Word or Google Docs and saving in a format from which pandoc can convert directly.

What is Pandoc used for?

Pandoc is a command-line tool for converting files from one markup language to another. Markup languages use tags to annotate sections of a document. Commonly used markup languages include Markdown, ReStructuredText, HTML, LaTex, ePub, and Microsoft Word DOCX.

Can Pandoc convert HTML to markdown?

Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx.

Where are Pandoc templates?

The default LaTeX template of Pandoc can be found at https://github.com/jgm/pandoc/tree/master/data/templates (named default. latex ).


2 Answers

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

like image 73
Mohamed Ragab Avatar answered Oct 15 '22 11:10

Mohamed Ragab


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.

like image 42
George D Girton Avatar answered Oct 15 '22 12:10

George D Girton