【问题标题】:Can I change the Pandoc typesetting engine to XeTeX or LuaTex?我可以将 Pandoc 排版引擎更改为 XeTeX 或 LuaTex 吗?
【发布时间】:2026-01-04 06:35:01
【问题描述】:

我正在尝试在我的文档中使用 Arial 字体并将 Markdown 转换为 Latex。我在我的乳胶模板中包含以下内容:

\usepackage{fontspec}
\setmainfont{Arial}

当我正常使用它时,这可以工作并将字体更改为 Arial,但是当我使用 Pandoc 转换为 PDF 时,我收到错误:

Error producing PDF.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Fatal fontspec error: "cannot-use-pdftex"
! 
! The fontspec package requires either XeTeX or LuaTeX.
! 
! You must change your typesetting engine to, e.g., "xelatex" or
! "lualatex"instead of plain "latex" or "pdflatex".
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.28 \msg_fatal:nn {fontspec} {cannot-use-pdftex}

它说这个包需要 XeTeX 或 LuaTex。我已经尝试了很多方法来将字体更改为 Arial,但到目前为止没有任何效果。

我使用 OS X。

【问题讨论】:

    标签: latex pandoc


    【解决方案1】:

    在使用 Pandoc 创建 pdf 时使用 LuaTex:

    pandoc test.txt --pdf-engine=lualatex -o test.pdf
    

    相应地申请XeTex:

    pandoc test.txt --pdf-engine=xelatex -o test.pdf
    

    来自 Pandoc Manual

    --pdf-engine=pdflatex|lualatex|xelatex|wkhtmltopdf|weasyprint|prince|context|pdfroff

    在生成 PDF 输出时使用指定的引擎。默认是 乳胶。如果引擎不在您的 PATH 中,则 可以在此处指定引擎。

    查看手册的Demo Section - 大部分用例都在其中介绍。

    【讨论】:

    • 感谢您告诉我!但是现在我收到一个错误File ucharcat.sty not found. 我搜索了 template.latex 文件,但它不存在。
    • 这意味着ucharcat.sty 要么没有安装,要么在Latex 没有找到它的地方。因为这是一个完全不同的问题:在TeX.SE 上搜索sty not found。如果这无助于解决问题,您可以在那里提出一个新问题。
    最近更新 更多