在同一个 Bookdown 项目中有一个 beamer_presentation 和一个 pdf_book
Having a beamer_presentation and a pdf_book in the same Bookdown project
在我的 Bookdown 项目中,我在 _output.yml
中指定了 bookdown::pdf_book
和 beamer_presentation
。 (为什么?这里是an example, and here is the explanation。)
问题是 pdf_book
似乎尊重 _bookdown.yml
中指定的 output_dir
,而不是 beamer_presentation
。因此,当点击 Build Book
按钮时,演示文稿不会进入 docs
目录,它会出现在基本目录中。
有什么方法可以让 beamer_presentation
遵守 output_dir
规范吗?
(此外,这意味着必须对文件名做一些事情,因为默认情况下名称是相同的。)
编辑:我意识到使用 bookdown::beamer_presentation2
而不是 beamer_presentation
将解决问题,因为它会尊重 output_dir
。但我称之为部分答案,正如我在最后一句话中的恐惧所实现的那样:这只会覆盖 pdf_book
(因为它们确实具有相同的名称),所以它仍然没有真正起作用.. .
是的,您需要使用 bookdown::beamer_presentation2
,这将遵循 _bookdown.yml
中的 output_dir
设置。
关于您的第二个问题(两种格式具有相同的输出文件名),如果您只想单击 RStudio 中的 Knit 按钮,目前没有很好的解决方案---您必须调用 rmarkdown::render()
并在调用中指定输出文件名,例如,
rmarkdown::render('file.Rmd', 'bookdown::pdf_book', output_file = 'book.pdf')
rmarkdown::render('file.Rmd', 'bookdown::beamer_presentation2', output_file = 'beamer.pdf')
在我的 Bookdown 项目中,我在 _output.yml
中指定了 bookdown::pdf_book
和 beamer_presentation
。 (为什么?这里是an example, and here is the explanation。)
问题是 pdf_book
似乎尊重 _bookdown.yml
中指定的 output_dir
,而不是 beamer_presentation
。因此,当点击 Build Book
按钮时,演示文稿不会进入 docs
目录,它会出现在基本目录中。
有什么方法可以让 beamer_presentation
遵守 output_dir
规范吗?
(此外,这意味着必须对文件名做一些事情,因为默认情况下名称是相同的。)
编辑:我意识到使用 bookdown::beamer_presentation2
而不是 beamer_presentation
将解决问题,因为它会尊重 output_dir
。但我称之为部分答案,正如我在最后一句话中的恐惧所实现的那样:这只会覆盖 pdf_book
(因为它们确实具有相同的名称),所以它仍然没有真正起作用.. .
是的,您需要使用 bookdown::beamer_presentation2
,这将遵循 _bookdown.yml
中的 output_dir
设置。
关于您的第二个问题(两种格式具有相同的输出文件名),如果您只想单击 RStudio 中的 Knit 按钮,目前没有很好的解决方案---您必须调用 rmarkdown::render()
并在调用中指定输出文件名,例如,
rmarkdown::render('file.Rmd', 'bookdown::pdf_book', output_file = 'book.pdf')
rmarkdown::render('file.Rmd', 'bookdown::beamer_presentation2', output_file = 'beamer.pdf')