设置 RSTUDIO_PDFLATEX 环境变量后,Rstudio 找不到 pdflatex

时间:2021-01-16 03:14:40

标签: rstudio pdflatex

我已经安装了 Latex,并在 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

1 个答案:

答案 0 :(得分:0)

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

不过,如果有人知道如何使用RSTUDIO_PDFLATEX,欢迎留言!