这是我第一次尝试使用 r 和 RStudio 生成报告。当我使用 RStudio 和 knitr 按钮以 html 格式创建文档时,该过程完成得很好,没有错误。但是,当我尝试相同的方法制作文档 .pdf 时,就会发生错误。
要从 rmarkdown 文件创建 .pdf 文档,我已经安装了 rmarkdown、knitr、tinytex,我还安装了 TinyTeX(来自 R 和 tinytex)和 PANDOC,执行时的错误tinytex :: pdflatex ('test.tex')
如下:
> tinytex::pdflatex('test.tex')
Sorry, no translations available for es_ES (nor es); falling back to English.
Make sure that you have the package "texlive-msg-translations" installed.
(If you'd like to help translate the installer's messages, please see
https://tug.org/texlive/doc.html#install-tl-xlate for information.)
tlmgr update --all --self
warning: kpathsea: configuration file texmf.cnf not found in these directories: ...
Sorry, no translations available for es_ES (nor es); falling back to English.
Make sure that you have the package "texlive-msg-translations" installed.
(If you'd like to help translate the installer's messages, please see
https://tug.org/texlive/doc.html#install-tl-xlate for information.)
tlmgr.pl: package repository https://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr.pl install: package already present: kpathsea
Sorry, no translations available for es_ES (nor es); falling back to English.
Make sure that you have the package "texlive-msg-translations" installed.
(If you'd like to help translate the installer's messages, please see
https://tug.org/texlive/doc.html#install-tl-xlate for information.)
! warning: kpathsea: configuration file texmf.cnf not found in these directories: ...
! ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
! warning: kpathsea: mktexfmt output `c:/Users/Jos<e9>Carlos/AppData/Roaming/TinyTeX/texmf-var/web2c/pdftex/pdflatex.fmt' instead of a filename.
! warning: kpathsea: mktexfmt output `c:/Users/Jos<e9>Carlos/AppData/Roaming/TinyTeX/texmf-var/web2c/pdftex/pdflatex.fmt' instead of a filename.
! warning: kpathsea: configuration file texmf.cnf not found in these directories: ...
! ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
! warning: kpathsea: mktexfmt output `c:/Users/Jos<e9>Carlos/AppData/Roaming/TinyTeX/texmf-var/web2c/pdftex/pdflatex.fmt' instead of a filename.
Error: LaTeX failed to compile test.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test.log for more info.
Además: Warning messages:
1: In xfun::read_utf8(f2) :
The file C:\Users\JOSCAR~1\AppData\Local\Temp\RtmpKW4Z5j\stderr1f3c1e9738a0 is not encoded in UTF-8. These lines contain invalid UTF-8 characters: 1, 3, 7, 8
2: In xfun::read_utf8(f2) :
The file C:\Users\JOSCAR~1\AppData\Local\Temp\RtmpKW4Z5j\stderr1f3c1d92194c is not encoded in UTF-8. These lines contain invalid UTF-8 characters: 1, 3, 7, 8
> tinytex::xelatex('test.tex')
升级 1
从 RStudio knitr / knitr 运行到 PDF,生成一个 .log 文件
! warning: kpathsea: configuration file texmf.cnf not found in these directories: ...
! ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
! warning: kpathsea: mktexfmt output `c:/Users/Jos<e9>Carlos/AppData/Roaming/TinyTeX/texmf-var/web2c/pdftex/pdflatex.fmt' instead of a filename.
! warning: kpathsea: configuration file texmf.cnf not found in these directories: ... ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
! warning: kpathsea: mktexfmt output `c:/Users/Jos<e9>Carlos/AppData/Roaming/TinyTeX/texmf-var/web2c/pdftex/pdflatex.fmt' instead of a filename.
升级 2
使用 rmarkdown::render("esfuerzo local social EELL.rmd", "pdf_document") 运行,结果与 .log 文件的相同内容相同。
另外,我显示回溯结果
Error: LaTeX failed to compile esfuerzo-local-social-EELL.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See esfuerzo-local-social-EELL.log for more info.
12. stop(e, " See ", logfile, " for more info.", call. = FALSE)
11. show_latex_error(file, logfile)
10. on_error()
9. system2_quiet(engine, c("-halt-on-error", "-interaction=batchmode", engine_args, shQuote(file)), error = { if (install_packages) tlmgr_update(run_fmtutil = FALSE, .quiet = TRUE) ...
8. run_engine()
7. on_error()
6. system2_quiet(engine, c("-halt-on-error", "-interaction=batchmode", engine_args, shQuote(file)), error = { if (install_packages) tlmgr_update(run_fmtutil = FALSE, .quiet = TRUE) ...
5. run_engine()
4. latexmk_emu(file, engine, bib_engine, engine_args, min_times, max_times, install_packages, clean)
3. tinytex::latexmk(file, engine, if (biblatex) "biber" else "bibtex")
2. latexmk(texfile, output_format$pandoc$latex_engine, "--biblatex" %in% output_format$pandoc$args)
1. rmarkdown::render("esfuerzo local social EELL.rmd", "pdf_document")
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)
升级 3
使用 RStudio 文件/新文件/R Markdown 和 knitr/knitr to PDF 按钮生成基本文档,错误是相同的,这里是 .log 文件
! warning: kpathsea: configuration file texmf.cnf not found in these directories: ...! ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
! warning: kpathsea: mktexfmt output `c:/Users/Jos<e9>Carlos/AppData/Roaming/TinyTeX/texmf-var/web2c/pdftex/pdflatex.fmt' instead of a filename.
! warning: kpathsea: configuration file texmf.cnf not found in these directories: ...! ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...éCarlos\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is C:\Users\Jos<e9>Carlos\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
! warning: kpathsea: mktexfmt output `c:/Users/Jos<e9>Carlos/AppData/Roaming/TinyTeX/texmf-var/web2c/pdftex/pdflatex.fmt' instead of a filename.
测试.Rmd
```
---
title: "test"
author: "José Carlos"
date: "21/5/2021"
output:
pdf_document: default
html_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
```