bookdown: customize the output filename
Asked Answered
R

1

7

This is a follow up to an earlier question I asked here: creating accompanying slides for bookdown project Bookdown allows compiling the file to various format, including multiple pdf. The issue is therefore to give the output different names. If not, the second pdf compile overwrites the first one!

In the comments to my earlier question, I wrote: "I just need to understand how to change the file name - because bookdown::pdf_book and bookdown::pdf_document2 output to the same file - which gets therefore overwritten! I know how to change filenames and locations for all files at once using _bookdown.yml, but I do not know how to do it for individual files.... i will search more online, but did not see anything so far - do I need to post another question for this if I cannot find anything?"
YiHui Xie responded: "Unfortunately you cannot customize the output filename through any YAML options"
I suggested: "i guess the only option if so would be to hope for a future version of bookdown to allow for some extra options such as bookdown::slides for instance?"
and added "I tried to pass "-o", "FILE.pdf" and variations to pandoc, but that did not seem to work"
Throwing this did not work either: pandoc_args: [ "--output", "slides.pdf" ]
but I do not think anyone noticed this question anymore and therefore, I am throwing this as an actual question, please, with the hope of finding a solution! many thanks in advance. thomas

Ruffled answered 17/6, 2019 at 22:51 Comment(1)
I also would love such an option.Honshu
R
4

For those who might be interested in an answer, I asked the question directly on (GitHub), and the package author Xie YiHui kindly responded:

The only way at the moment is to render (bookdown::render_book()) to the default output filename, rename it (file.rename()), then render the next output format, and also rename the output file to your desired filename. This process could be automated via an R script. I don't have time for a more detailed answer. Sorry.

Ruffled answered 22/8, 2019 at 16:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.