Different Rmarkdown to PDF compiler behavior with RMarkown and Bookdown

I'm working on a largish Bookdown project with 10 .rmd input files, a lot of figures and tables and about 200 pages (so far) as a pdf. A few days ago I successfully compiled my project to pdf using the tufte::tufte2 book set up. After lunch I tried to compile it again and got a number of errors related to bad bioliography references and missing dollar signs. Each file individually compiles successfully with simple Rmarkdown to pdf. Also if I remove two .rmd files from the folder, bookdown compiles successfully but when I add them back, failure. The specific error that stops compilation

! Missing inserted. <inserted text>
l.419 \textbf{Scalars} & A scal & ar \in
& dex{da & ta obj & ects!scalar} ...

Try to find the following text in _main.Rmd:
\textbf{Scalars} & A scal & ar \in

RMarkdown code:

Scalars A scalar \index{data objects!scalar}

Compilation errors:
After conversion to the _main.tex file

\textbf{Scalars} & A scal & ar \in & dex{da & ta obj & ects!scalar}

I think this is a red herring issue because without those 2 files, the book compiles and produces a pdf.

In addition, another issue has popped when creating figures from rmarkdown chunks. All the figures generated in the rmarkdown code have the axis scales and titles cut off and just the plot portion of the figure filling the page margins. This happens only when producing a tufte_handout or book .pdf. In html, the figures are as they should be. This is happening in both bookdown and plain RMarkdown, and has never happened before in the 10+ years I've been using these tools. Even the prototype .rmd file when a new rMarkdown document is created has this problem with the figure margins and scales.

I've reinstalled both RStudio and R (4.1.3) and run update.packages() to refresh the R libraries. None of this helped.

Something is seriously wrong here and I don't know what to do next. Any thoughts are appreciated.

Hi @dkStevensNZed

Is this the same issues as in this other one ?

This seems to be related to some content in your Rmd file. Can you share the Rmd content related the tex output ? probably some missing escaping somehow :thinking: maybe the & ?

I believe this could be related to cropping. By default, fig_crop = TRUE in tufte::tufte_book() and it seems it does not play well with some of your images. Can you try setting fig_crop = FALSE ?
Cropping only happens in PDF output not HTML. The default behavior may have changed some time ago on Windows, but it has been a while. Hopefully deactivating cropping will solve this issue.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.