You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Pandoc排版引擎切换为XeTeX/LuaTeX?Arial字体转PDF报错求助

Solution: Switch Pandoc's PDF Engine to XeTeX or LuaTeX

Absolutely, you can switch Pandoc's typesetting engine to XeTeX or LuaTeX to fix this issue—here's exactly how to do it:

The error you’re seeing happens because Pandoc defaults to using pdfLaTeX by default, and the fontspec package (which you’re using to load Arial) only works with XeTeX or LuaTeX. These engines support modern font handling that pdfLaTeX doesn’t.

1. Specify the engine directly in your Pandoc command

When converting your Markdown file to PDF, add the --pdf-engine flag to tell Pandoc to use XeLaTeX or LuaTeX instead of pdfLaTeX.

For XeLaTeX (the most common choice for working with fontspec):

pandoc your-document.md -o output.pdf --pdf-engine=xelatex

For LuaTeX (a lightweight alternative with similar font support):

pandoc your-document.md -o output.pdf --pdf-engine=lualatex

Keep your existing LaTeX template code (\usepackage{fontspec} \setmainfont{Arial}) intact—XeLaTeX/LuaTeX will recognize it correctly and apply the Arial font as you expect.

2. Set a default engine for all Pandoc conversions (optional)

If you don’t want to type the --pdf-engine flag every time, you can set a default in Pandoc’s configuration file:

  • On Linux/macOS: Create or edit ~/.pandoc/pandoc.yaml
  • On Windows: Create or edit %APPDATA%\pandoc\pandoc.yaml

Add this line to the file:

pdf-engine: xelatex

Now Pandoc will automatically use XeLaTeX for all PDF conversions unless you specify a different engine explicitly.

Since you already got Arial working with your local LaTeX setup, your system has the font installed, so you shouldn’t run into missing font issues once you switch the engine.

内容的提问来源于stack exchange,提问作者themthem

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:35:10