2

我使用 tineytex 包,当我单击 rStudio 中的 knit 按钮时,编织 pdf 没有问题。但是,当我rmarkdown::render()使用相同的 .Rmd 文件作为输入调用时,目标文件夹中只生成了一个中间的 .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 --to latex --from 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 tango --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) (preloaded format=pdflatex) 已启用 \write18。警告:kpathsea://enterprise2/Users4$/Sqhuang_a/My Documents:无法识别的变量构造$/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents: Unrecognized variable construct$/'。警告:kpathsea://enterprise2/Users4$/Sqhuang_a/My Documents:无法识别的变量构造$/'. 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 Documents/.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 Documents/.TinyTeX/texmf-home/web2c:无法识别的变量构造“$/”。进入扩展模式错误:无法编译 \endeavor/apps_doc$/Applications/0_Support/GCS/Brett - Other Duties/BAR/Steph/AL/Jul/test_report.tex。调试技巧见 https://yihui.name/tinytex/r/#debugging

4

1 回答 1

1

我已经解决了这个问题(不幸的是,我似乎遇到了另一个问题,但我想我已经解决了这个问题)。

基本上,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/.TinyTeXwith的地方./TinyTeX,这将使 kpathsea 在我实际安装 TinyTex 的目录中搜索(更具体地说,不在默认目录中搜索。)

希望这可以帮助任何遇到此问题的人,并为开发人员提供一些帮助,帮助他们了解如何在未来阻止此问题。

于 2020-03-04T22:56:20.713 回答