2
votes

I use tineytex package and have no problem knitting a pdf when I click on the knit button in rStudio. However, when I called rmarkdown::render() with the same .Rmd file as input, only an intermeidate .tex file was generated in the target folder.

Below is my code.

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

Below is the error messages that I got.

processing file: 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

output file: 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" This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX) (preloaded format=pdflatex) restricted \write18 enabled. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents: Unrecognized variable construct $/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents: Unrecognized variable construct$/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents: Unrecognized variable construct $/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents/.TinyTeX/texmf-config/web2c/pdftex: Unrecognized variable construct$/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents/.TinyTeX/texmf-var/web2c/pdftex: Unrecognized variable construct $/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents/.TinyTeX/texmf-home/web2c/pdftex: Unrecognized variable construct$/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents/.TinyTeX/texmf-config/web2c: Unrecognized variable construct $/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents/.TinyTeX/texmf-var/web2c: Unrecognized variable construct $/'. warning: kpathsea: //enterprise2/Users4$/Sqhuang_a/My Documents/.TinyTeX/texmf-home/web2c: Unrecognized variable construct `$/'. entering extended mode Error: Failed to compile \endeavor/apps_doc$/Applications/0_Support/GCS/Brett - Other Duties/BAR/Steph/AL/Jul/test_report.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips.

1
I have added the following in my .Rmd file code trunk: options(tinytex.verbose = TRUE). But, not much details regarding the error was given. I also searched on the internet and found someone posting the same issue in Rstudio forum, but the issue was not resolved. Did anyone ran into this problem and had the issue resolved? Any pointers to obtaining more information about the issue is greatly appreciated.Stephanie Wong
When rendering an HTML version of the same report, render() also failed. However, I got more information regarding the error this time. It was the cooperate share drive that the render() function had issues with: it could not properly interpret the share drive path which contains a $. Once I changed the output directory to C drive, both pdf and html versions of the report were rendered.Stephanie Wong
(Just for the record) Similar question asked here: github.com/yihui/tinytex/issues/150 but I don't have a solution.Yihui Xie

1 Answers

1
votes

I think I've figured out the problem (unfortunately, I seem to have ran into a further issue, but I think I've resolved this one anyway).

Basically, kpathsea is searching everywhere in your system for the needed packages. This means it's trying to search in directories that it can't read properly (because of the $ symbol amongst others). The solution was to find the texmf.cnf file which looks something like this:

% (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,

When searching, kpathsea replaces the $HOME with a directory, which contains a $, e.g., for me $HOME gets replaced by my default Documents folder (which is on a shared network drive).

I replaced anywhere that had a $HOME/.TinyTeX with ./TinyTeX, which would make kpathsea search in the directory where I have actually installed the TinyTex (and, more specifically to not search in the default directory.)

Hope this helps anybody having this issue and provides some help for developers on how to maybe stop this problem in the future.