! LuaTeX-ja error: File `jfm-zh_CN.lua' not found.
## 问题描述
当 Quarto 文档里有中文字符,生成的 PDF 时会报错:
```
! LuaTeX-ja error: File `jfm-zh_CN.lua' not found.
```
AI 告诉我的解决方法:
> 你使用的是 TinyTeX,可能缺少必要的中文支持包。运行以下命令安装缺失组件:
>
> ```bash
> tlmgr install luatexja ctex chinese-jfm
> ```
>
> 这会安装 LuaTeX 中文支持包、ctex 宏包以及所需的 JFM 配置文件。
注:我发现 Quarto 把生成中文的 XeLaTeX 换成了 LuaLeTeX,~~不知道从哪个版本开始的~~从 [1.8 版本](https://github.com/quarto-dev/quarto-cli/blob/v1.8.24/news/changelog-1.8.md)开始,我目前的 Quarto 版本是 1.8.25
```
Rendering PDF
running lualatex - 1
This is LuaHBTeX, Version 1.22.0 (TeX Live 2025)
restricted system commands enabled.
```
## 我的代码
````qmd
---
title: "代码块含有带双引号的中文字符测试"
lang: zh
format:
pdf:
documentclass: article
include-in-header: "preamble.tex"
---
```{r}
name = c("张三", '李四')
name
```
````
`preamble.tex` 文件代码:
```tex
\usepackage[UTF8,fontset=none]{ctex}
\setCJKmainfont{Noto Serif CJK SC}
\setCJKsansfont{Noto Sans CJK SC}
\setCJKmonofont{Noto Sans Mono CJK SC}
```
## 我的环境
``` r
xfun::session_info()
#> R version 4.5.1 (2025-06-13)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Arch Linux
#>
#> Locale:
#> LC_CTYPE=zh_CN.UTF-8 LC_NUMERIC=C
#> LC_TIME=zh_CN.UTF-8 LC_COLLATE=zh_CN.UTF-8
#> LC_MONETARY=zh_CN.UTF-8 LC_MESSAGES=zh_CN.UTF-8
#> LC_PAPER=zh_CN.UTF-8 LC_NAME=C
#> LC_ADDRESS=C LC_TELEPHONE=C
#> LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=C
#>
#> Package version:
#> base64enc_0.1.3 bslib_0.9.0 cachem_1.1.0 callr_3.7.6
#> cli_3.6.5 clipr_0.8.0 compiler_4.5.1 digest_0.6.37
#> evaluate_1.0.5 fastmap_1.2.0 fontawesome_0.5.3 fs_1.6.6
#> glue_1.8.0 graphics_4.5.1 grDevices_4.5.1 highr_0.11
#> htmltools_0.5.8.1 jquerylib_0.1.4 jsonlite_2.0.0 knitr_1.50
#> lifecycle_1.0.4 memoise_2.0.1 methods_4.5.1 mime_0.13
#> processx_3.8.6 ps_1.9.1 R6_2.6.1 rappdirs_0.3.3
#> reprex_2.1.1 rlang_1.1.6 rmarkdown_2.30.1 rstudioapi_0.17.1
#> sass_0.4.10 stats_4.5.1 tinytex_0.57 tools_4.5.1
#> utils_4.5.1 withr_3.0.2 xfun_0.53 yaml_2.3.10
tinytex::tlmgr_version()
#> tlmgr revision 75204 (2025-05-13 23:48:24 +0200)
#> tlmgr using installation: /home/cxy/.TinyTeX
#> TeX Live (https://tug.org/texlive) version 2025
```
<sup>Created on 2025-10-20 with [reprex v2.1.1](https://reprex.tidyverse.org)</sup>
3 条评论