5

I'd like to use bookdown to parse a series of .Rmd file into a book. If I have my .Rmd in the same directory as the main index.Rmd file then everything works fine and dandy. However, the .Rmd files are autogenerated from another source and I'd like to keep the input files in a subdirectory. Is it possible to do that?

I can include the file names in _bookdown.yml but I'd prefer not having to update that file every time a new .Rmd file is added.

The current version of _bookdown.yml looks like this

new_session: yes
rmd_files:
  html: ["input/index.Rmd", "input/01-file.Rmd"]
  latex: ["input/index.Rmd", "input/01-file.Rmd"]

I can move the files in a script but was hoping it was possible through bookdown itself.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
ekstroem
  • 5,957
  • 3
  • 22
  • 48
  • 4
    You can set `rmd_subdir` to `true` so Rmd files in subdirectories are also used and you do not have to explicitly list them in `rmd_files`: https://bookdown.org/yihui/bookdown/configuration.html – Yihui Xie Nov 14 '16 at 05:10
  • Ah yes thank you. But that searches through *all* subdirectories. Is it possible to name specific sub directories as, e.g., `rmd_subdir: [ 'input/' ]`. In any case your comment answered my immediate question. – ekstroem Nov 14 '16 at 15:58
  • 1
    That is not possible for now, but it sounds like a useful feature to be added. You can file a feature request to https://github.com/rstudio/bookdown/issues – Yihui Xie Nov 15 '16 at 02:56

1 Answers1

5

In the development version of bookdown you can now provide a list of subdirectories to be search recursively.

For example to have it search dir1/ and dir2/ (and their subdirectories) you can specify rmd_subdir: ["dir1/", "dir2/"] in the _bookdown.yml.

Ellis Valentiner
  • 2,136
  • 3
  • 25
  • 36
  • hi Ellis, do you know if this is now available in bookdown 0.7? I can't get it working. Created a new bookdown project via Rstudio, copied all (except index.Rmd) to new folder and set the rmd_subdir: ["new_folder"]. However only the index.Rmd is shown. Note I am running under windows maybe that is the problem. I have asked this question also on stackoverflow – Floris Padt Aug 07 '18 at 19:55
  • @FlorisPadt I have answered your question: https://stackoverflow.com/a/51735752/559676 – Yihui Xie Aug 07 '18 at 21:36