无法从RMarkdown(tinytex)生成pdf报告

无法从RMarkdown(tinytex)生成pdf报告,pdf,r-markdown,rstudio,tinytex,Pdf,R Markdown,Rstudio,Tinytex,直到最近,我才能够从Rmd文件创建pdf 由于遇到麻烦,我按照建议更新了tinytex并更新了所有软件包(我曾经让Miktex和我改为tinytex) 以这个基本的例子: --- title: "This is a report" output: pdf_document: keep_tex: yes --- ```{r setup, include=FALSE} knitr::opts

直到最近,我才能够从Rmd文件创建pdf

由于遇到麻烦,我按照建议更新了tinytex并更新了所有软件包(我曾经让Miktex和我改为tinytex)

以这个基本的例子:

    ---
    title: "This is a report"
    output: 
      pdf_document: 
        keep_tex: yes
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
    options(tinytex.verbose = TRUE)
    ```
    
    This is a report

我收到以下错误:

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS reports.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output reports.tex --lua-filter "D:\Mes Donnees\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "D:\Mes Donnees\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in" 
output file: reports.knit.md

This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/W32TeX) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
I was unable to find any missing LaTeX packages from the error log reports.log.
! I can't write on file `reports.pdf'.
(Press Enter to retry, or Control-Z to exit; default file extension is `.pdf')
Please type another file name for output
! Emergency stop.
<to be read again> 
                   \edef 
l.76 \begin{document}

! Emergency stop.
<to be read again> 
                   \edef 
l.76 \begin{document}

Error: LaTeX failed to compile reports.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See reports.log for more info.
Execution halted

创建xdv文件时没有任何问题。 然后我尝试使用

xdvipdfmx -vv ess.xdv
然后出现了一个问题:

<FONTMAP:c:/Users/djourdain/AppData/Roaming/TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map><FONTMAP:c:/Users/djourdain/AppData/Roaming/TinyTeX/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map><FONTMAP:c:/Users/djourdain/AppData/Roaming/TinyTeX/texmf-dist/fonts/map/dvipdfmx/ckx.map>DVI Comment:  XeTeX output 2021.03.17:0716
ess.xdv -> ess.pdf

xdvipdfmx:fatal: Unable to open "ess.pdf".

No output PDF file written.
DVI注释:XeTeX输出2021.03.17:0716
ess.xdv->ess.pdf
xdvipdfmx:致命:无法打开“ess.pdf”。
未写入输出PDF文件。
pdf文件似乎被锁定在某个地方。但是,我没有要求预览pdf文件,也没有在目录中预先存在任何ess.pdf

合计 出于绝望,我再次尝试在一个新的项目目录中使用一个没有空格的名称(D:/Ess),而不是一个有空格的目录(D:/Mes Donnees/Ess/),这一次效果很好


在早期版本中,我从未遇到任何目录名问题。Rmarkdown或tinytex中是否发生了导致此新问题的任何更改?

是的,Rmarkdown 1.8和Rmarkdown 1.9之间发生了更改

Rmarkdown 1.8调用Pandoc将Markdown转换为PDF,在此过程中有一个中间步骤,临时更改某些文件的路径,消除导致问题的空白

由于Rmarkdown 1.9,因此没有Pandoc步骤。因此,临时更改路径的中间步骤不再存在,空格会产生错误

但是,空格导致此错误的根本原因并不十分清楚


Rmarkdown GitHub repo的评论,特别是易慧的评论,都是关于这一点的详细信息,值得一读。

您是否尝试过编织默认的
Rmd
模板?如果您使用的是RStudio,则当您单击文件->新建文件->R标记->PDFThk you@canovasjm时,会显示此模板。是的,我尝试使用默认值,但错误是相同的!是否生成文件
reports.log
?如果是这样,那里可能有有用的信息。我添加了reports.log,并使用了另一种策略,运行到一个新的空目录中,分解dvi和pdf文件的创建。问题似乎在于访问ess.pdf文件。但是,我从未预览过该文件,也没有在目录中预先存在它?
xdvipdfmx -vv ess.xdv
<FONTMAP:c:/Users/djourdain/AppData/Roaming/TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map><FONTMAP:c:/Users/djourdain/AppData/Roaming/TinyTeX/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map><FONTMAP:c:/Users/djourdain/AppData/Roaming/TinyTeX/texmf-dist/fonts/map/dvipdfmx/ckx.map>DVI Comment:  XeTeX output 2021.03.17:0716
ess.xdv -> ess.pdf

xdvipdfmx:fatal: Unable to open "ess.pdf".

No output PDF file written.