gpt4 book ai didi

r - 为 bookdown 项目创建随附幻灯片

转载 作者:行者123 更新时间:2023-12-01 18:58:22 25 4
gpt4 key购买 nike

在 Rstudio 中,我创建一个新项目并使用 bookdown 选择图书项目。内置示例按预期完美运行,我可以编译 4 本书 - gitbook、html、epub 和 pdf。太棒了。

下一个明显的步骤是希望同时播放幻灯片,这与 beamer 包 的功能非常一致,允许 beamer 模式文章模式。因此,我尝试在 _output.yml 代码中添加另一个输出:bookdown::pdf_document2。根据文档,我知道我应该能够定义 base_format 来使用 rmarkdown::beamerThe package author told me I was almost right, see this link for the discussion 。妙语:我将修改后的 _output.yml 用于默认项目:

bookdown::gitbook:
css: style.css
config:
toc:
before: |
<li><a href="./">A Minimal Book Example</a></li>
after: |
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
download: ["pdf", "epub"]
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
includes:
in_header: preamble.tex
latex_engine: xelatex
citation_package: natbib
keep_tex: yes
bookdown::epub_book: default
bookdown::pdf_document2:
includes:
in_header: preamble.tex
latex_engine: xelatex
citation_package: natbib
keep_tex: yes

这正是谢一辉善意的建议。但是,当需要构建 pdf_book 时,我遇到编译失败:

Output created: _book/index.html
Error in base_format(toc = toc, number_sections = number_sections, fig_caption = fig_caption, :
unused argument (number_sections = number_sections)
Calls: <Anonymous> ... <Anonymous> -> create_output_format -> do.call -> <Anonymous>
Execution halted

Exited with status 1.

我迷失了 - 我花了几个小时寻找解决方案但没有成功。有人可以帮助我吗?很抱歉我没能弄清楚这个问题。谢一辉给予了极大的支持,他的评论表明这是提出此类问题的正确场所。非常感谢。托马斯

最佳答案

该错误是由于 rmarkdown::beamer_presentation() 没有参数 number_sections (您无法在 beamer 中对节进行编号;至少 Pandoc 没有)似乎不支持)。

要解决此问题,您可以使用以下技巧,它基本上定义了一个丢弃 number_sections 参数的基本格式:

---
title: "Using bookdown with Beamer"
output:
bookdown::pdf_book:
base_format: "function(..., number_sections) rmarkdown::beamer_presentation(...)"
number_sections: false
---

## Plot

See Figure \@ref(fig:foo).

```{r, foo, fig.cap='Hi there', fig.height=4}
plot(1:10)
```

关于r - 为 bookdown 项目创建随附幻灯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52429949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com