rmarkdown :: render()无法生成pdf,但是rstudio的“编织”按钮有效

时间:2019-09-03 19:55:41

标签: r-markdown render tinytex

我使用tineytex软件包,单击rStudio中的“编织”按钮时,编织pdf没问题。但是,当我使用相同的.Rmd文件作为输入调用rmarkdown::render()时,在目标文件夹中仅生成了一个intermeidate .tex文件。

下面是我的代码。

rmarkdown::render(input = "C:/Users/sqhuang/Pdf.Rmd",  
           output_format = "pdf_document",
           output_file = "test.pdf", 
            output_dir = ot_path)

下面是我收到的错误消息。

处理文件:Pdf.Rmd

|.........                                                        |  14%
  ordinary text without R code

  |...................                                              |  29%
label: setup (with options) 
List of 1
 $ echo: logi FALSE

  |............................                                     |  43%
  ordinary text without R code

  |.....................................                            |  57%
label: cars
  |..............................................                   |  71%
  ordinary text without R code

  |........................................................         |  86%
label: pressure (with options) 
List of 1
 $ echo: logi FALSE

  |.................................................................| 100%
  ordinary text without R code

输出文件:Pdf.knit.md

  

“ C:/ PROGRA〜1 / Pandoc / pandoc” + RTS -K512m -RTS Pdf.utf8.md-至乳胶   -来自markdown + autolink_bare_uris + ascii_identifiers + tex_math_single_backslash   --output pandoc15f027594a1c.tex --template“ C:\ PROGRA〜1 \ R \ R-36〜1.1 \ library \ RMARKD〜1 \ rmd \ latex \ DEFAUL〜3.TEX”   --highlight-style探戈--pdf-engine pdflatex --variable graphics = yes --variable“ geometry:margin = 1in” --variable“ compact-title:yes”这是pdfTeX,版本3.14159265-2.6-1.40.20 (TeX Live 2019 / W32TeX)   (预加载格式= pdflatex)已启用\ write18。警告:   kpathsea:// enterprise2 / Users4 $ / Sqhuang_a /我的文档:无法识别   变量构造$/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents: Unrecognized variable construct $ /'。警告:kpathsea:// enterprise2 / Users4 $ / Sqhuang_a / My   文档:无法识别的变量构造$/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents/.TinyTeX/texmf-config/web2c/pdftex: Unrecognized variable construct $ /'。警告:kpathsea:// enterprise2 / Users4 $ / Sqhuang_a / My   Documents / .TinyTeX / texmf-var / web2c / pdftex:无法识别的变量   构造$/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents/.TinyTeX/texmf-home/web2c/pdftex: Unrecognized variable construct $ /'。警告:kpathsea:// enterprise2 / Users4 $ / Sqhuang_a / My   文档/.TinyTeX/texmf-config/web2c:无法识别的变量构造   $/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents/.TinyTeX/texmf-var/web2c: Unrecognized variable construct $ /'。警告:kpathsea:// enterprise2 / Users4 $ / Sqhuang_a / My   文档/.TinyTeX/texmf-home/web2c:无法识别的变量构造   $ /。进入扩展模式错误:无法编译   \ endeavor / apps_doc $ / Applications / 0_Support / GCS / Brett-其他   职责/BAR/Steph/AL/Jul/test_report.tex。看到   https://yihui.name/tinytex/r/#debugging以获得调试提示。

1 个答案:

答案 0 :(得分:1)

认为我已经解决了这个问题(不幸的是,我似乎遇到了further issue,但我认为我已经解决了这个问题)。

基本上,kpathsea会在系统中的所有位置搜索所需的软件包。这表示正在尝试在无法正确读取的目录中进行搜索(因为其中存在$符号)。解决方案是找到看起来像这样的texmf.cnf文件:

% (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
%
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
%
TEXMFLOCAL = $SELFAUTOPARENT/texmf-local
TEXMFHOME = $HOME/.TinyTeX/texmf-home
TEXMFVAR = $HOME/.TinyTeX/texmf-var
TEXMFCONFIG = $HOME/.TinyTeX/texmf-config
OSFONTDIR = $SystemRoot/fonts//
ASYMPTOTE_HOME = $TEXMFCONFIG/asymptote

% Prefer external Perl for third-party TeXLive Perl scripts
% Was set to 1 if at install time a sufficiently recent Perl was detected.
TEXLIVE_WINDOWS_TRY_EXTERNAL_PERL = 0
TEXMFAUXTREES = C:/PROGRA~1/R/R-36~1.3/share/texmf,

搜索时,kpathsea将$HOME替换为包含$的目录,例如,对我来说$HOME被我的默认Documents文件夹替换(位于共享网络上)驱动器。)

我用$HOME/.TinyTeX替换了具有./TinyTeX的任何地方,这将在我实际安装TinyTex的目录中进行kpathsea搜索(更具体地说,是不是在默认目录中搜索。)

希望这可以帮助遇到此问题的任何人,并为开发人员提供一些帮助,以帮助他们日后如何解决此问题。