Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why some R codes have to be included in index.Rmd of Bookdown?

I downloaded bookdown-chinese at Bookdown Chinese demo and removed all the .Rmd files except index.Rmd. When I built the book, why some R codes have to be included in index.Rmd,.

```{r}
 sessionInfo()
```

otherwise some errors would be prompted

! Undefined control sequence.
l.105 \RecustomVerbatimEnvironment
                              {Highlighting}{Verbatim}{commandchars=\\\{...

Error: Failed to compile bookdown.tex. See bookdown.log for more info.
Please delete bookdown.Rmd after you finish debugging the error.
Execution halted

Exited with status 1.

in fact I edited a book without block R codes, and found I have to keep those R codes or changed any others R codes in index.Rmd in order build the book.

like image 312
Minyi Han Avatar asked May 31 '18 23:05

Minyi Han


People also ask

How do I hide code in R Markdown?

Chunk Optionsinclude = FALSE prevents code and results from appearing in the finished file. R Markdown still runs the code in the chunk, and the results can be used by other chunks. echo = FALSE prevents code, but not the results from appearing in the finished file.

How do you enter R code in R Markdown?

You can insert an R code chunk either using the RStudio toolbar (the Insert button) or the keyboard shortcut Ctrl + Alt + I ( Cmd + Option + I on macOS).

What is inline R code?

Inline R code is embedded in the narratives of the document using the syntax `r ` . In the above example, we defined a variable x in a code chunk, which is the radius of a circle, and calculated its area in the next paragraph.


1 Answers

The LaTeX command that is causing this error comes from preamble.tex and is defined in the LaTeX package fancyvrb. In template.tex we see that fancyvrb is included only conditionally. And indeed, in bookdown.tex that is present when this error is produced, fancyvrb is not loaded.

If you are sure that you will not need R chunks in the future, you can simply remove the offending line from preamble.tex. If you might use R chunks in the future, have a look at this PR.

like image 73
Ralf Stubner Avatar answered Sep 27 '22 02:09

Ralf Stubner