bookdown: customize the output filename

青春壹個敷衍的年華 提交于 2020-03-14 11:07:58

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/56639760/bookdown-customize-the-output-filename

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!