2

In my Bookdown project, I have both a bookdown::pdf_book and a beamer_presentation specificed in the _output.yml. (Why? Here is an example, and here is the explanation.)

The problem is that pdf_book seems to respect the output_dir specified in _bookdown.yml, but not the beamer_presentation. Thus, when hitting the Build Book button, the presentation won't get into the docs directory, it'll appear in the base directory.

Is there any way to make beamer_presentation respect the output_dir specification?

(Also, it'll mean that something has to be done with the filenames, as by default the the names would be the same.)

EDIT: I realized that using bookdown::beamer_presentation2 instead of beamer_presentation will solve the problem, as it'll respect the output_dir. But I'd call it a partial answer, as my fears in the last sentence realized: this will simply overwrite the pdf_book (as they'll indeed have the same name), so it is still not really working...

Tamas Ferenci
  • 424
  • 2
  • 10
  • Doesn't this look like a duplicate of https://stackoverflow.com/questions/56639760/bookdown-customize-the-output-filename ? – tchevrier Mar 05 '20 at 18:48
  • @tchevrier The original question (how to respect `output_dir`) was not a duplicate, but the later question in "EDIT" is. I'm okay if anyone wants to vote to close this post as a duplicate. – Yihui Xie Mar 05 '20 at 20:11
  • Yes, its really a "half-duplicate" now, thanks @tchevrier for mentioning that question. – Tamas Ferenci Mar 07 '20 at 07:25

1 Answers1

2

Yes, you need to use bookdown::beamer_presentation2, which will respect the output_dir setting in _bookdown.yml.

Regarding to your second problem (two formats having the same output filename), there isn't a nice solution at the moment if you only want to click the Knit button in RStudio---you have to call rmarkdown::render() and specify the output filename in the call, e.g.,

rmarkdown::render('file.Rmd', 'bookdown::pdf_book', output_file = 'book.pdf')
rmarkdown::render('file.Rmd', 'bookdown::beamer_presentation2', output_file = 'beamer.pdf')
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
  • Thanks very much for the answer! Do you have any prediction whether this feature (i.e. that the output file's name can be specified in `_bookdown.yml`, so that Render button will be sufficient) will ever be implemented? I totally understand that there is no timeline you can promise, just an approximation (I have no idea how complicated this would be). – Tamas Ferenci Mar 05 '20 at 11:16
  • again, this solution looks like a duplicate of the one you provided for https://stackoverflow.com/questions/56639760/bookdown-customize-the-output-filename ? I also raised this issue in your related post: https://stackoverflow.com/questions/58885889/embedding-a-beamer-presentation-in-a-regular-document-with-rmarkdown/60552065#60552065 +1 would be nice feature to have... – tchevrier Mar 05 '20 at 18:50
  • 2
    @tchevrier Thanks for the reminder! I have totally forgotten it, but will definitely reconsider it in the future since the [Github issue](https://github.com/rstudio/bookdown/issues/737) is still open. – Yihui Xie Mar 05 '20 at 20:08
  • 1
    Now you know why we all love you so much! :-) – tchevrier Mar 06 '20 at 06:15
  • Thank you both! I am really happy that it has an open issue on Github, I already subscribed to its notification. Hope it'll be resolved one day :) Thanks again! – Tamas Ferenci Mar 07 '20 at 07:27
  • and if you could somehow help to get pandoc to revert from the idiotic behavior of slapping non-slide content onto a slide - that would be really much appreciated. At this time, it's just me alone fighting against windmills... Don Quichotte style. – tchevrier Mar 07 '20 at 07:40