使用Pandoc将Markdown转换为PDF,因为Xetex已被弃用

10

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

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

但是 markdown2pdf 已经失效了,在 markdown2pdf -N -o ../../Desktop/pandoc_output.pdf --xetex --toc --template=mytemplate-headers-garamond_date.tex 中的--xetex选项已经被弃用。
如果我这样做:
$ pandoc -N -o Desktop/pandoc_output.pdf  --xetex --toc --template=mytemplate.tex myfile.md

I get this:

pandoc: unrecognized option `--xetex'

但是如果我去掉 --xetex 并执行以下操作:

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

然后我得到了这个:
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}

有什么解决方案?

3个回答

20
尝试使用--pdf-engine=xelatex而不是--xetex
在Pandoc 2.0之前,发布于2017年,这个选项被称为--latex-engine。如果你使用的是非常旧的Pandoc版本(使用pandoc --version检查),你可能需要使用这个选项。

2
现在这个已经被弃用了,请使用--pdf-engine代替。 - volvox

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模板后(导致出现'you don't have BEGIN {'错误),我得到了.PDF:换句话说,默认模板起作用了。
此外,我错误地输入了“-t pdf”(上面没有显示)以将pdf设置为输出格式,但这是不正确的。输出格式是Latex,然后将其转换为PDF。使用短横线-t选项指定输出格式是不必要的。
希望我的一些小失误记录能为某人节省时间。

0
请参阅pandoc用户指南(或man页面)以获取--latex-engine选项的详细信息。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接