bookdown:自定义输出文件名 [英] bookdown: customize the output filename
问题描述
这是我在此处提出的早期问题的后续:创建随附幻灯片预订项目Bookdown
允许将文件编译为各种格式,包括多个 pdf
.因此,问题是给输出不同的名称.如果没有,第二个 pdf
编译会覆盖第一个!
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!
在对我之前的问题的评论中,我写道:我只需要了解如何更改文件名 - 因为 bookdown::pdf_book
和 bookdown::pdf_document2
输出到同一个文件 - 因此会被覆盖!我知道如何使用 _bookdown.yml
一次更改所有文件的文件名和位置,但我不知道如何为单个文件执行此操作....我将在网上搜索更多内容,但目前没有看到任何内容 - 如果我找不到任何内容,我是否需要为此发布另一个问题?"
YiHui Xie 回应:很遗憾,您无法通过任何 YAML
选项自定义输出文件名"
我建议:如果是这样,我想唯一的选择是希望 bookdown
的未来版本允许一些额外的选项,例如 bookdown::slides
?
并添加了我试图将 "-o"、FILE.pdf"
和变体传递给 pandoc
,但这似乎不起作用"
抛出这个也不起作用:pandoc_args: [ "--output", "slides.pdf" ]
但我认为没有人再注意到这个问题了,因此,我将此作为一个实际问题抛出,希望能找到解决方案!提前谢谢了.托马斯
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
推荐答案
对于那些可能对答案感兴趣的人,我直接在 (GitHub),包作者谢义辉亲切回应:
For those who might be interested in an answer, I asked the question directly on (GitHub), and the package author Xie YiHui kindly responded:
目前唯一的方法是将 (bookdown::render_book()) 渲染为默认输出文件名,重命名(file.rename()),然后渲染下一个输出格式,并将输出文件重命名为您的所需的文件名.这个过程可以通过 R 脚本自动化.一世没有时间做更详细的答案.对不起.
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.
这篇关于bookdown:自定义输出文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!