首页 > 解决方案 > 设置 RSTUDIO_PDFLATEX 环境变量后,Rstudio 找不到 pdflatex

问题描述

我已经安装了乳胶,并在 RSTUDIO_PDFLATEX 环境变量中指定了路径。但它仍然无法找到它,并一直让我安装我不想安装的 Miktex 或 tinytex。有谁知道为什么?

> Sys.getenv("RSTUDIO_PDFLATEX")
[1] "/home/victor/local/texlive/2020/bin/x86_64-linux/pdflatex"
/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS ddd.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output ddd.tex --lua-filter /home/victor/R/x86_64-pc-linux-gnu-library/3.6/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/victor/R/x86_64-pc-linux-gnu-library/3.6/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in' 
output file: ddd.knit.md

! sh: 1: pdflatex: not found

Error: LaTeX failed to compile ddd.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See ddd.log for more info.
In addition: Warning message:
In system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) :
  error in running command
Execution halted

No LaTeX installation detected (LaTeX is required to create PDF output). You should install a LaTeX distribution for your platform: https://www.latex-project.org/get/

  If you are not sure, you may install TinyTeX in R: tinytex::install_tinytex()

  Otherwise consider MiKTeX on Windows - http://miktex.org

标签: rstudiopdflatex

解决方案


我把texlive的add目录放到系统环境变量PATH中,然后REBOOT系统,Rstudio终于可以找到pdflatex了!

但是,如果有人知道如何使用 RSTUDIO_PDFLATEX,欢迎发表评论!


推荐阅读