Windows下运行Rmarkdown生成PDF时LaTeX编译失败求助
Windows下Rmarkdown生成PDF报错解决方案建议
错误信息
! ...וסף\AppData\Roaming\TinyTeX\bin\windows\runscript.tlu:941: ...וסף\AppData\Roaming\TinyTeX\bin\windows\runscript.tlu:864: no appropriate script or program found: fmtutil Running the command C:\Users\���� ����\AppData\Roaming\TinyTeX\bin\windows\fmtutil-user.exe Error: LaTeX failed to compile gg.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See gg.log for more info. In addition: There were 27 warnings (use warnings() to see them) Execution halted
环境信息
R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18362) Locale: LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C LC_TIME=English_United States.utf8 time zone: Asia/Hebron tzcode source: internal Package version: base64enc_0.1.3 bslib_0.4.2 cachem_1.0.7 cli_3.6.1 digest_0.6.31 ellipsis_0.3.2 evaluate_0.20 fastmap_1.1.1 fontawesome_0.5.1 fs_1.6.2 glue_1.6.2 graphics_4.3.0 grDevices_4.3.0 highr_0.10 htmltools_0.5.5 jquerylib_0.1.4 jsonlite_1.8.4 knitr_1.42 lifecycle_1.0.3 magrittr_2.0.3 memoise_2.0.1 methods_4.3.0 mime_0.12 R6_2.5.1 rappdirs_0.3.3 rlang_1.1.1 rmarkdown_2.21 sass_0.4.5 stats_4.3.0 stringi_1.7.12 stringr_1.5.0 tinytex_0.45 tools_4.3.0 utils_4.3.0 vctrs_0.6.2 xfun_0.39 yaml_2.3.7 Pandoc version: 2.19.2 > tinytex::tinytex_root() [1] "C:\\Users\\עידן יוסף\\AppData\\Roaming\\TinyTeX"
系统PATH输出
> Sys.getenv('PATH') [1] "c:\\rtools43\\x86_64-w64-mingw32.static.posix\\bin;c:\\rtools43\\usr\\bin;C:\\Program Files\\R\\R-4.3.0\\bin\\x64;C:\\Program Files (x86)\\Razer Chroma SDK\\bin;C:\\Program Files\\Razer Chroma SDK\\bin;C:\\Program Files (x86)\\Razer\\ChromaBroadcast\\bin;C:\\Program Files\\Razer\\ChromaBroadcast\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\עידן יוסף\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\עידן יוסף\\AppData\\Roaming\\TinyTeX\\bin\\windows;C:\\Program Files\\RStudio\\resources\\app\\bin\\quarto\\bin;C:\\Program Files\\RStudio\\resources\\app\\bin\\postback"
额外命令输出
执行tinytex::tlmgr_path()无输出;执行file.info(p)得到:
> file.info(p) size isdir mode mtime ctime C:\\Users\\עידן יוסף\\AppData\\Roaming/TinyTeX/bin/win32/pdflatex.exe NA NA <NA> <NA> <NA> atime exe C:\\Users\\עידן יוסף\\AppData\\Roaming/TinyTeX/bin/win32/pdflatex.exe <NA> <NA>
解决建议
重新安装TinyTeX:从报错来看,
fmtutil和pdflatex.exe无法被识别,大概率是安装包损坏或不完整。执行以下命令彻底重装:tinytex::uninstall_tinytex() tinytex::install_tinytex()卸载后关闭所有R/RStudio窗口,再重新打开执行安装命令。
规避非ASCII路径:你的用户名包含希伯来文,Windows下部分程序对特殊字符路径支持差,可能导致文件读取失败。可以将TinyTeX安装到无特殊字符的路径:
tinytex::install_tinytex(dir = "C:/TinyTeX")安装后手动将
C:\TinyTeX\bin\windows添加到系统环境变量PATH最前端,重启电脑生效。手动验证LaTeX程序:打开Windows命令提示符,输入
pdflatex --version,如果提示找不到命令,说明路径配置错误。手动修复PATH后重启电脑,再回到RStudio尝试编译。查看详细日志:打开报错中提到的
gg.log文件,里面有更具体的LaTeX编译错误细节,能帮你定位缺失的包或配置问题。
内容的提问来源于stack exchange,提问作者TaL
相关产品推荐
相关产品推荐

