bookdown

conditionally embed video in R-markdown (bookdown)

∥☆過路亽.° 提交于 2021-02-08 09:12:12
问题 If I simply copy and paste an HTML code provided by YouTube into a .Rmd file, this works fine for gitbook output. Here is an example of the code <iframe width="560" height="315" src="https://www.youtube.com/embed/9AI3BkKQhn0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen> </iframe> However, I get error messages for PDF and EPUB outputs. In order to avoid this, I thought I could use conditional compilation, e.g. ```{r} if (knitr

How to speed up bookdown generation?

怎甘沉沦 提交于 2021-02-08 07:53:49
问题 I'm currently working on a book using bookdown. It uses some code snippets which take time to compile, execute and get output. I use the following commands to build HTML, PDF and EPUB files for the book: Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')" Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::pdf_book')" Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::epub_book')" So, every time the book files are generated the actual computation takes place

R markdown / bookdown - how to display keywords below an abstract?

爷,独闯天下 提交于 2021-02-07 20:47:27
问题 I defined keywords in the .Rmd file, but they are not visible in the output PDF. Current Output Expected results Current .Rmd First lines of .Rmd file looks as follows: --- title: "No keywords within the output file" abstract: "This is sample text for abstract. Generally speaking, I would like to show keywords list below an abstract (as in case of the linked example)" keywords: "keywordA, keywordB" author: "Mateusz Kędzior" output: bookdown::pdf_document2: keep_tex: true number_sections: yes

How to number table with chapter number

北城以北 提交于 2021-02-07 20:44:29
问题 I inclue and cross-referencing a table in a Rmd file, and I want to add chapter number with the table title and referencing number, like "TABLE 1.1 test", but not "TABLE 1 test". I render the file using bookdown::word_document2. Here is a minimal example: --- title: test output: bookdown::word_document2: fig_caption: yes toc: yes --- ```{r} library(knitr) ``` # Heading 1 I'm cross-referencing a table table:\@ref(tab:test). ```{r test} test <- data.frame(a = 1:6, b = 2:7) kable(test, caption =

R markdown / bookdown - how to display keywords below an abstract?

狂风中的少年 提交于 2021-02-07 20:41:41
问题 I defined keywords in the .Rmd file, but they are not visible in the output PDF. Current Output Expected results Current .Rmd First lines of .Rmd file looks as follows: --- title: "No keywords within the output file" abstract: "This is sample text for abstract. Generally speaking, I would like to show keywords list below an abstract (as in case of the linked example)" keywords: "keywordA, keywordB" author: "Mateusz Kędzior" output: bookdown::pdf_document2: keep_tex: true number_sections: yes

How to number table with chapter number

家住魔仙堡 提交于 2021-02-07 20:40:29
问题 I inclue and cross-referencing a table in a Rmd file, and I want to add chapter number with the table title and referencing number, like "TABLE 1.1 test", but not "TABLE 1 test". I render the file using bookdown::word_document2. Here is a minimal example: --- title: test output: bookdown::word_document2: fig_caption: yes toc: yes --- ```{r} library(knitr) ``` # Heading 1 I'm cross-referencing a table table:\@ref(tab:test). ```{r test} test <- data.frame(a = 1:6, b = 2:7) kable(test, caption =

How to use inline R code in a bookdown theorem or example environment

a 夏天 提交于 2021-02-07 12:23:31
问题 I use bookdown to generate documents in both html and PDF. How could I use results from inline R code in theorem and example environments? Here is what I tried: --- title: "Test" output: bookdown::pdf_book: toc: false html_document: toc: false --- ```{r} a <- 2 b <- 3 ``` If $a = `r a`$ and $b = `r b`$, then $a + b = `r a + b`$. ```{theorem} If $a = `r a`$ and $b = `r b`$, then $a + b = `r a + b`$. ``` ```{example} If $a = `r a`$ and $b = `r b`$, then $a + b = `r a + b`$. ``` and I get 回答1:

Pandoc #4317 forces content under title slides to be included in a frame in pandoc > 2.7

孤者浪人 提交于 2021-02-04 16:24:27
问题 In this question I explained my goal: creating accompanying slides for a bookdown project. I chose the Beamer format for the slides and was happy. However, upgrading to Pandoc 2.7 onwards (>2.6) caused my project to produce undesired slides. Specifically, any previously ignored content is now thrown into an ad-hoc slide! I find this behavior quite odd, as my understanding was that choosing slide_level: 3 meant ### was needed to create a slide! After insane amount of hours, I found what caused

How to use gitbook plugin in gitbook style bookdown

痴心易碎 提交于 2021-01-29 14:48:28
问题 There is a simple procedure to put buttons for copying code of gitbooks. What would be the way to do that in a bookdown? # install npm curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt-get install -y nodejs # install gitbook builder sudo npm install -g gitbook sudo npm install -g gitbook-cli # git clone gitbook "example" repository git clone ... cd gitbook/ npm init # Install plugin to add clipboard button for code # https://www.npmjs.com/package/gitbook-plugin-copy

Bookdown does not render image in output pdf

牧云@^-^@ 提交于 2021-01-29 14:09:43
问题 I'm trying to include an image in the example index.rmd file that comes with the bookdown-package within RStudio. (New Project -> Book Project using bookdown) I then simply appended the following code within an R code-chunk. ```{r} knitr::include_graphics("png_logo.png") ``` Running the code chunk on its own produces the expected output (shows figure). However, if I use the following command in the terminal: bookdown::render_book("index.Rmd", "bookdown::pdf_book") a pdf-file is produced, that