1

Following @yihui's bookdown usage 1.3, I'm attempting to select specific files to render in each output format by adding a rmd_files argument to _bookdown.yml in @yihui's Minimal Book Example.

rmd_files:
  html: ["index.Rmd", "01-intro.Rmd"]
  latex: ["index.Rmd", "01-intro.Rmd"]
  epub: ["index.Rmd", "01-intro.Rmd"]
  word: ["index.Rmd", "01-intro.Rmd"]

To _output.yml, I add

bookdown::word_document2:
  toc: true

Everything else in the Minimal Book Example is unchanged.

rmarkdown::render_site(encoding = 'UTF-8') renders html, latex, and epub documents, but word output fails with Error in basename(files) : a character vector argument expected Calls: <Anonymous> ... FUN -> render_book -> source_files -> grep -> basename

The word document renders if I remove the rmd_files argument.

I tried omitting index.Rmd from the files list, deleting all content from both Rmd files, and using word_document instead of word_document2.

Same results with CRAN bookdown_0.20 and development version 0.20.3 on two different machines (both macs).

This error may be similar to this post, but it did not provide a minimal example and appears to have been fixed in the latest bookdown release.

Bookdown is amazing, and I could be missing something simple here. Thanks so much for any help!

1 Answers1

1

The name of the output format is docx instead of word.

rmd_files:
  docx: ["index.Rmd", "01-intro.Rmd"]

The name is for Pandoc, and all names are listed here: https://pandoc.org/MANUAL.html#option--to

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
  • 1
    Thank you! This could be useful to note in 1.3 since the other options have the same names as output options given--"LaTeX, HTML, EPUB, and Word". It's obvious in hindsight, but it looks others have been confused by this little mismatch (e.g. https://www.barelysignificant.com/post/old/blogdown/). Thanks again! – Devin Judge-Lord Sep 07 '20 at 19:55
  • 1
    @DevinJudge-Lord Since this is too confusing, I just made `word` work automatically: https://github.com/rstudio/bookdown/commit/4bff22cd447015ce5ebe953e562dc2d2b5490685 Thanks! – Yihui Xie Sep 08 '20 at 02:27