My Problem
I've been using seamlessly R's bookdown for a couple of weeks now until I've encountered the following error when running it's default template (skeleton) in RStudio:
output file: _main.knit.md
! Paragraph ended before \MT#prot#l was complete.
<to be read again>
\par
l.141
Error: LaTeX failed to compile _main.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See _main.log for more info.
Execution halted
Error: bookdown::render_book() failed to render the output format 'bookdown::pdf_book'.
Execution halted
Exited with status 1.
My Initial Diagnosis
The html version bookdown::gitbook() is still working! When I commented-out as follows the bookdown::pdf_book() portion in the _output.yml file, the book rendered with all the LaTeX equations. Moreover, bookdown::epub_book() still also works.
bookdown::gitbook:
css: style.css
config:
toc:
before: |
<li>A Minimal Book Example</li>
after: |
<li>Published with bookdown</li>
edit: https://github.com/USERNAME/REPO/edit/BRANCH/%s
# download: ["pdf", "epub"]
# bookdown::pdf_book:
# includes:
# in_header: preamble.tex
# latex_engine: xelatex
# citation_package: natbib
# keep_tex: yes
# bookdown::epub_book: default
I have resintalled RStudio, R, Rtools (with path included) TinyTex and updated everything as suggested in https://yihui.org/tinytex/r/#debugging but still of no avail.
My _main.log File
For reference, my _main.log file is here: https://github.com/rvcuenca/default_bookdown_template/blob/main/_main.log
My sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 knitr_1.36.9 magrittr_2.0.1 usethis_2.1.5 gert_1.4.3
[6] R6_2.5.1 rlang_0.4.12 fastmap_1.1.0 fansi_0.5.0 httr_1.4.2
[11] tools_4.1.2 sys_3.4 xfun_0.28.10 utf8_1.2.2 cli_3.1.0
[16] withr_2.4.3 gitcreds_0.1.1 htmltools_0.5.2 askpass_1.1 ellipsis_0.3.2
[21] rprojroot_2.0.2 openssl_1.4.5 yaml_2.2.1 digest_0.6.29 tibble_3.1.6
[26] lifecycle_1.0.1 crayon_1.4.2 bookdown_0.24.4 purrr_0.3.4 vctrs_0.3.8
[31] fs_1.5.2 credentials_1.3.2 curl_4.3.2 glue_1.5.1 evaluate_0.14
[36] rmarkdown_2.11.3 gh_1.3.0 pillar_1.6.4 compiler_4.1.2 jsonlite_1.7.2
[41] pkgconfig_2.0.3
My Question
Any thoughts where could have I went wrong?
Related
devtools::build_manual() produces Error: Failed to build manual (at least on windows).
Steps to reproduce:
create a new R project on R Studio.
Add this documentation for the hello_world function, document and build the package.
#' Hello world doc
#'
#' #export
#'
hello <- function() {
print("Hello, world!")
}
Try running devtools::build_manual()
Error: Failed to build manual
This seems to be a recent issue; I could build my packages manuals not too long ago. I tried the check_manual() function in this issue, and this is what I get:
> check_man()
Checking: hello.RdError: Failed to build manual
Called from: value[[3L]](cond)
Browse[1]> e
System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last 10 lines):
E> ima/AppData/Roaming/TinyTeX/texmf-dist/fonts/type1/urw/times/utmb8a.pfb><c:/Use
E> rs/plima/AppData/Roaming/TinyTeX/texmf-dist/fonts/type1/urw/times/utmr8a.pfb><c
E> :/Users/plima/AppData/Roaming/TinyTeX/texmf-dist/fonts/type1/urw/times/utmri8a.
E> pfb>
E> Output written on Rd2.pdf (1 page, 50650 bytes).
E> Transcript written on Rd2.log.
E> Warning in sys2(makeindex, shQuote(idxfile)) : '"makeindex"' not found
E> Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
E> unable to run 'makeindex' on 'Rd2.idx'
E> Error in running tools::texi2pdf()
I don't know what to do with this output. All I know is that I could build manuals not too long ago.
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] manualtest_0.1.0
loaded via a namespace (and not attached):
[1] magrittr_2.0.1 usethis_2.0.1 devtools_2.4.2 pkgload_1.2.1 R6_2.5.0 rlang_0.4.11
[7] fastmap_1.1.0 fansi_0.5.0 tools_4.1.0 pkgbuild_1.2.0 sessioninfo_1.1.1 utf8_1.2.2
[13] cli_3.0.1 withr_2.4.2 ellipsis_0.3.2 remotes_2.4.0 rprojroot_2.0.2 tibble_3.1.3
[19] lifecycle_1.0.0 crayon_1.4.1 processx_3.5.2 purrr_0.3.4 callr_3.7.0 vctrs_0.3.8
[25] fs_1.5.0 ps_1.6.0 testthat_3.0.4 memoise_2.0.0 glue_1.4.2 cachem_1.0.5
[31] pillar_1.6.1 compiler_4.1.0 desc_1.3.0 prettyunits_1.1.1 pkgconfig_2.0.3
Running tinytex::tlmgr_install("makeindex") solved the issue, without the need to reinstall tinytex.
I'm new to targets ecosystem. I could not create a distill article from my targets pipeline although it works when I set the output to html_document in yaml. I have tried googling but couldn't find anything useful. Any help would be appreciated.
My RStudio is version 1.4.1717. I got this error message upon running tar_make():
Error: callr subprocess failed: Distill articles cannot be previewed in this version of RStudio.
Please update to version 1.2.718 or higher at https://www.rstudio.com/products/rstudio/download/
Visit https://books.ropensci.org/targets/debugging.html for debugging advice.
Run `rlang::last_error()` to see where the error occurred.
Here is a minimal code example.
Code in _targets.R
library(targets)
library(tarchetypes)
tar_plan(
tar_target(dat, iris),
tar_render(test_report, "test.Rmd")
)
Here are the contents of my Rmd file. Most of them are from the template.
---
title: "Test"
description: |
A new article created using the Distill format.
author:
- name: Nora Jones
url: https://example.com/norajones
affiliation: Spacely Sprockets
affiliation_url: https://example.com/spacelysprokets
date: "`r Sys.Date()`"
output: distill::distill_article
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r load-targets, include=FALSE}
tar_load(dat)
```
```{r}
summary(dat)
```
Session info
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] igraph_1.2.6 rstudioapi_0.13 knitr_1.33 magrittr_2.0.1 tidyselect_1.1.1
[6] R6_2.5.1 rlang_0.4.11 fansi_0.5.0 tools_4.1.0 targets_0.7.0
[11] data.table_1.14.0 xfun_0.25 utf8_1.2.2 cli_3.0.1 withr_2.4.2
[16] ellipsis_0.3.2 yaml_2.2.1 digest_0.6.27 tibble_3.1.3 lifecycle_1.0.0
[21] crayon_1.4.1 processx_3.5.2 purrr_0.3.4 callr_3.7.0 vctrs_0.3.8
[26] ps_1.6.0 codetools_0.2-18 glue_1.4.2 compiler_4.1.0 pillar_1.6.2
[31] pkgconfig_2.0.3
I've been having the same issue.
From here you can see that distill checks for the version first by trying the rstudioapi (which fails) and then by looking for an environment variable called "RSTUDIO_VERSION", which does not exist on my system. When this fails, it uses a default value of 1.1, which fails the check of having at least version 1.2.7...
There is a simple, if slightly hacky, solution which is to just manually set the environment variable that distill is looking for at the top of your script. I.e., your Rmd file would become:
---
title: "Test"
description: |
A new article created using the Distill format.
author:
- name: Nora Jones
url: https://example.com/norajones
affiliation: Spacely Sprockets
affiliation_url: https://example.com/spacelysprokets
date: "`r Sys.Date()`"
output: distill::distill_article
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
# Add environment variable
Sys.setenv("RSTUDIO_VERSION" = '1.4.1725')
```
```{r load-targets, include=FALSE}
tar_load(dat)
```
```{r}
summary(dat)
```
This works totally fine for me. If you're worried about this having ongoing effects, you can remove it afterwards (Sys.unsetenv("RSTUDIO_VERSION"))
I get a compiling error when trying to render an R markdown script as pdf.
Knitting the markdown file with content below with the knit button in RStudio, or running the command knitr::knit('test.Rmd'), gives an error.
---
title: "Untitled"
output: pdf_document
---
##
```{r}
mod <- lm(speed ~ dist, data=cars)
jtools::summ(mod)
```
The error message I get is:
! LaTeX Error: Undefined color `gray!6'.
Note that when load the latex package xcolor in the preamble (as below) I get another error message but at least it compiles and renders a pdf.
---
title: "Untitled"
output:
pdf_document:
extra_dependencies: ["xcolor"]
---
##
```{r}
mod <- lm(speed ~ dist, data=cars)
jtools::summ(mod)
```
I get the same error when compiling a report from an R script. Note that I'm asking students to compile a report for a class exercise, so I don't want to lose them by having them play around with additional latex packages.
Also, apologies if this is the wrong forum, but because it's specific to an R package (things render to pdf just fine in general), it seemed like the right place for this question.
Below is my sessionInfo() in case this is helpful.
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8
[6] LC_MESSAGES=en_CA.UTF-8 LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 rstudioapi_0.11 knitr_1.29 magrittr_1.5 tidyselect_1.1.0 munsell_0.5.0 colorspace_1.4-1 R6_2.4.1
[9] rlang_0.4.7 dplyr_1.0.1 tools_4.0.2 grid_4.0.2 gtable_0.3.0 xfun_0.16 htmltools_0.5.0 ellipsis_0.3.1
[17] yaml_2.2.1 digest_0.6.25 tibble_3.0.3 lifecycle_0.2.0 crayon_1.3.4 purrr_0.3.4 ggplot2_3.3.2 jtools_2.1.0
[25] vctrs_0.3.2 glue_1.4.1 evaluate_0.14 rmarkdown_2.3 pander_0.6.3 compiler_4.0.2 pillar_1.4.6 generics_0.0.2
[33] scales_1.1.1 pkgconfig_2.0.3
I followed the "LaTeX packages used in this package" section in kableExtra's awesome_table_in_pdf vignette.
header-includes:
- \usepackage{xcolor}
It wasn't necessary when I knitted the document normally through RStudio. But it was when I had to do some unconventional things with a shared drive. (That's when I got the "! LaTeX Error: Undefined color `gray!6'." error.)
Complete yaml header:
title: SO Question
output:
pdf_document:
toc: FALSE
number_sections: TRUE
geometry: margin=2cm
header-includes:
- \usepackage{xcolor}
I'm trying to type up some statistics notes for one of my classes in bookdown. bookdown is not rendering the text written for any chapter with subsections. There is a bunch of text within each subsection, but it is not showing up when I compile to pdf.
Any ideas about what could be causing the problem?
The only thing that shows up is the section headers for the chapter. Sometimes deleting the files in _book is a workaround, but I can't reproduce the error easily. Everything seems to work, then I add a little text, and then I have the rendering problem. The document seems to compile with no warnings. A screenshot of the what I'm getting is included.
I'm running the most current version of RStudio.
Session info:
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics
[3] grDevices utils
[5] datasets methods
[7] base
loaded via a namespace (and not attached):
[1] compiler_3.6.1
[2] bookdown_0.13.2
[3] htmltools_0.3.6
[4] tools_3.6.1
[5] yaml_2.2.0
[6] Rcpp_1.0.2
[7] rmarkdown_1.15
[8] knitr_1.25
[9] xfun_0.9
[10] digest_0.6.20
[11] packrat_0.5.0
[12] evaluate_0.14
My yaml header is:
title: "A Book"
author: "Frida Gomam"
site: bookdown::bookdown_site
documentclass: book
output:
bookdown::pdf_book:
includes:
in_header: preamble-latex.tex
# bookdown::gitbook:
# includes:
# before_body: preamble-mathjax.tex
bibliography: [book.bib]
biblio-style: apalike
You should click the Build Book button, instead of the Knit button. The latter only previews the current chapter. See documentation here: https://bookdown.org/yihui/bookdown/rstudio-ide.html
Following this answer I'm using titlesec package to get my headers in sans serif.
Looks pretty; however there seems to be a problem with latex titlesec package using rmarkdown. The bookmarks are confused, also the linking within the document is not working well (i.e. clicking the bookmark doesn't jump correctly to the header).
I'm showing an image of Acrobat Reader bookmarks with titlesec line activated (left) and commented out (right):
Any suggestions? I'm using MiKTeX.
MWE:
---
output: pdf_document
subparagraph: yes
header-includes:
- \usepackage{lipsum} # produces dummy text
- \usepackage[sf,bf]{titlesec} # titlesec line
---
# Header1
\lipsum[1]
## Header1.1
\lipsum[1-7]
### Header1.1.1
\lipsum[1-7]
## Header1.2
\lipsum[1-7]
### Header1.2.1
\lipsum[1-7]
Session info:
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland.1252
[3] LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_0.12.19 rstudioapi_0.8 knitr_1.20 magrittr_1.5 hms_0.4.2
[6] devtools_1.13.6 munsell_0.5.0 colorspace_1.3-2 rlang_0.2.2 tools_3.5.1
[11] data.table_1.11.8 rio_0.5.10 withr_2.1.2 htmltools_0.3.6 readxl_1.1.0
[16] yaml_2.2.0 rprojroot_1.3-2 digest_0.6.18 tibble_1.4.2 crayon_1.3.4
[21] zip_1.0.0 curl_3.2 memoise_1.1.0 evaluate_0.12 haven_1.1.2
[26] rmarkdown_1.10 openxlsx_4.1.0 cellranger_1.1.0 compiler_3.5.1 pillar_1.3.0
[31] scales_1.0.0 forcats_0.3.0 backports_1.1.2 foreign_0.8-71 pkgconfig_2.0.2