The CTeX fontset “fandol“ is unavailable in the current mode.
完整报错如下
The error message says that the CTeX fontset "fandol" is unavailable in the current mode. This usually happens when using the ctex package with pdfLaTeX, but the Fandol fonts are not installed or not supported in this mode.
A common fix is to switch to a different fontset (like "windows", "mac", or "adobe") or to use XeLaTeX or LuaLaTeX, which have better support for Chinese fonts.
I will suggest changing the fontset option in the ctex package to "adobe", which is widely supported.
Suggesting to change the ctex package option in the preamble.
I found \usepackage[UTF8]{ctex} in your preamble. To fix the error, I will change it to \usepackage[UTF8, fontset=adobe]{ctex}.
Suggesting this change now.
-
\usepackage[UTF8]{ctex}
-
\usepackage[UTF8, fontset=adobe]{ctex}
原因解释
你使用了 \usepackage[UTF8]{ctex}
,默认情况下 CTeX 会选择 fandol
字体作为中文字体(这是 TeX Live 中默认支持的一套开源中文字体)。但如果你选择了 pdfLaTeX 编译方式,而系统又找不到或不支持 Fandol 字体,就会报错。
解决方法
最推荐的方法是切换编译方式为 XeLaTeX 或 LuaLaTeX,这两种方式对中文支持更好,兼容性更强。
✅ 切换编译步骤
-
打开你的 Overleaf 项目
登录 Overleaf 后,进入你正在编辑的那个项目。 -
点击页面左上角的 “菜单(Menu)”
就在 Overleaf 编辑器界面左上角,有一个绿色按钮,写着 “Menu”。 -
找到 Compiler 设置
在弹出的菜单中,往下滑一点,找到 “Compiler” 设置项。 -
选择 XeLaTeX(推荐)或 LuaLaTeX
默认值通常是pdfLaTeX
,你可以点击下拉框,选择:-
XeLaTeX
✅(最推荐,支持中文最好) -
或
LuaLaTeX
-
-
点击右上角的 “Recompile” 按钮重新编译
完成设置后,点击编辑器右上角的绿色 “Recompile” 按钮进行重新编译。
你也可以在不更换编译器的情况下,手动指定一个支持的字体集,比如使用 adobe
字体集(这是 CTeX 支持的一种旧字体集,兼容性较好):
修改方法:
将你的导言区的:
\usepackage[UTF8]{ctex}
改成:
\usepackage[UTF8, fontset=adobe]{ctex}
另一种更推荐的方法(特别是在 Overleaf 上):
Overleaf 默认推荐用 XeLaTeX 编译中文文档。你只需要在菜单里将编译器改为 XeLaTeX,然后保留原来的语句:
\usepackage[UTF8]{ctex}
这样通常就不会有问题了。
总结建议:
-
✅ 最佳推荐:在 Overleaf 的“菜单” → “Compiler” 选择 XeLaTeX
-
✅ 如果你不能更换编译器,再使用
fontset=adobe
等方式指定字体集 -
❌ 不推荐使用 pdfLaTeX 编译中文文档,尤其是包含中文段落或标题时