自Xetex弃用以来使用Pandoc降价至PDF

inc*_*man 8 markdown latex xetex pandoc

在我的MacBook(OSX Mountain Lion)上,我曾经使用此Pandoc命令将Markdown转换为PDF:

$ markdown2pdf -N -o pandoc_output.pdf  --xetex --toc --template=mytemplate.tex myfile.md
Run Code Online (Sandbox Code Playgroud)

markdown2pdf不再有效,并且不推荐使用--xetex选项markdown2pdf -N -o ../../Desktop/pandoc_output.pdf --xetex --toc --template=mytemplate-headers-garamond_date.tex.

如果我这样做:

$ pandoc -N -o Desktop/pandoc_output.pdf  --xetex --toc --template=mytemplate.tex myfile.md
Run Code Online (Sandbox Code Playgroud)

我明白了:

pandoc: unrecognized option `--xetex'
Run Code Online (Sandbox Code Playgroud)

但如果我拿出--xetex来做这件事:

$ pandoc -N -o Desktop/pandoc_output.pdf  --toc --template=mytemplate.tex myfile.md
Run Code Online (Sandbox Code Playgroud)

然后我明白了:

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}
Run Code Online (Sandbox Code Playgroud)

解决方案是什么?

Moh*_*gab 17

尝试--latex-engine=xelatex而不是--xetex

  • 现在已弃用。使用 --pdf-engine 代替。 (2认同)

Geo*_*ton 6

这个问题的先前答案对我有帮助,因为我几年前安装了pandoc,但从未使用过Tex Live.因此我不知道我是否正确安装它,所以放入整个路径帮助我看到它正在工作,如下所示:

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

这是您从Pandoc安装页面下载的BasicTex设置的默认安装位置.

我也忘了使用pandoc -D Latex >my-latex-template.tex生成模板.在给出.tex模板而不是我的.html模板(导致'你没有BEGIN {'错误)之后,我得到了.PDF:换句话说,默认模板工作了.

另外,我输入-t pdf不正确(上面未显示)将pdf设置为输出格式,但这不正确.输出格式为Latex,然后转换为PDF.没有必要使用dash -t选项指定输出格式.

我希望我的轻微失误记录可以节省一些时间.