Knitting bug on pdf

This is just one of those days...

Any RMarkdown I try to knit to pdf gives me the errors

The system cannot find the path specified.
Error in if (fig_crop) { : missing value where TRUE/FALSE needed
Calls: <Anonymous> ... do.call -> <Anonymous> -> output_format -> knitr_options_pdf
Execution halted

This includes the default file created by RStudio as well as other markdown files that have been no problem heretofor.

I'm running the most up-to-date versions of RStudio and R on a Windows 10 machine.

Any clues???

Just long-shot but what latex compiler do you on your machine? Is it updated and registered correctly so R could find it?

1 Like

Hmmm. Given your comment I ran tinytex::reinstall_tinytex(). Now things seem to work. No idea what's going on, but if they work I'm happy.

The package tinytex cannot really be considered as a substitute for a real latex compiler on your machine. I myself work with MikTex and Tex-Live, there are other options.
If you ask CoPilot you get the following answer:
Yes, TinyTeX can indeed be used in place of other TeX distributions because it is essentially TeX Live. However, there are a few things to consider:

  1. TinyTeX is a lightweight, cross-platform, portable, and easy-to-maintain version of TeX Live. It provides helper functions to install and maintain the LaTeX distribution. These functions also allow you to compile LaTeX documents and automatically install missing LaTeX packages¹.

  2. Depending on the files you compile in tools like TeXStudio and LyX, as opposed to those you've already compiled in R, you might encounter errors. In such cases, you'll need to address each error by manually installing the missing package².

  3. If you use a copy of TeX Live or TinyTeX installed by your system admin and don't have privileges to modify it, some features may not work. However, if you installed TinyTeX on your personal computer, chances are it will work as expected³.

In summary, TinyTeX is a great option for lightweight and portable LaTeX usage, but be prepared to handle any missing package errors when working with other tools. :blush::page_facing_up::mag:

Source: Conversation with Bing, 20.4.2024
(1) Package 'tinytex' reference manual - rstudio.r-universe.dev. Package 'tinytex' reference manual.
(2) Can TinyTeX replace MiKTeX or TeX Live - LaTeX Stack Exchange. lyx - Can TinyTeX replace MiKTeX or TeX Live - TeX - LaTeX Stack Exchange.
(3) The R package tinytex - Helper Functions to Manage TinyTeX, and Compile .... The R package tinytex - Helper Functions to Manage TinyTeX, and Compile LaTeX Documents - Yihui Xie | 谢益辉.
(4) 1.2 Install LaTeX (TinyTeX) for PDF reports | R Markdown Cookbook. 1.2 Install LaTeX (TinyTeX) for PDF reports | R Markdown Cookbook.

My only use of latex is what happens implicitly when I push the knit button looking for a pdf file. Can you say more about what knit/RStudio does and whether you think it is adequate.

When you knit a document into PDF, R translates the document structure to Latex and compile it through your Latex compiler. TinyTex is a package, with all good intentions to substitute a full Latex compiler on your machine. Unfortunately, it lacks the ability to install additional fonts, glyphs and packages as you could normally do with a full Latex installation like MikTex. It also prevents you from seeing actual errors from Latex.

TLDR; With TinyTex you cannot see real error messages and even if you did you cannot install/upgrade missing Latex fonts, glyphs and packages when they cause errors.

Is there a recommended way to point knit to a better latex compiler?

Install one, I think it will recognize it automatically, at least it did for me with MikTex.

1 Like

I would suggest purging TinyTex first but like @ JonesYaniv I think R/RStudio should find a new LaTeX automatically.

1 Like