简体   繁体   English

我如何在R bookdown文档中包含toc_float?

[英]How can I have a toc_float in a R bookdown document?

I've been working on a report in r-markdown that is getting a bit lengthy and want to break it up into parts with bookdown . 我一直在研究r-markdown中的报告,该报告有些冗长,并且希望将其与bookdown一起bookdown I'm using a custom html template with a bootstrap menu bar that is enabled in yaml front-matter with: 我正在使用带有引导菜单栏的自定义html模板,该菜单栏已在yaml前端启用,并具有以下功能:

toc: true
toc_float: true

My reproducible example produces the following error: 我的可复制示例产生以下错误:

Error in html_document(fig_width = fig_width, fig_height = fig_height, : You must use a theme when specifying the 'toc_float' option Calls: ... -> base_format -> output_format -> html_document html_document中的错误(fig_width = fig_width,fig_height = fig_height,:指定'toc_float'选项时必须使用主题调用:...-> base_format-> output_format-> html_document

and when I include theme: default I get this error: 当我包含theme: default此错误:

Error in html_document(fig_width = fig_width, fig_height = fig_height, : formal argument "theme" matched by multiple actual arguments Calls: ... do.call -> -> base_format -> output_format html_document中的错误(fig_width = fig_width,fig_height = fig_height ,:由多个实际参数匹配的形式参数“ theme”调用:... do.call->-> base_format-> output_format

The document knits without toc_float , but my bootstrap menu bar disappears (as it was designed to do). 该文档在没有toc_float情况下进行toc_float ,但是我的引导菜单栏消失了(如设计那样)。

Any ideas? 有任何想法吗?

Parent doc: 上级文件:

---
title: "test doc"
output:
  bookdown::html_document2:
    # theme: default
    base_format: rmarkdown::html_vignette
    toc: true
    toc_float: true

---

```{r child = "chapters/01-child.Rmd"}
```

Child doc: 子文档:

#  Child

Child

If I understand this correctly, toc_float does not work with rmarkdown::html_vignette as you cannot set a theme. 如果我正确理解这一点,则toc_float不能与rmarkdown::html_vignette因为您无法设置主题。

From the documentation of rmarkdown::html_vignette : rmarkdown::html_vignette的文档中:

Additional arguments passed to html_document. 传递给html_document的其他参数。 Please note that theme, fig_retina and highlight are hard coded. 请注意,主题,fig_retina和Highlight是硬编码的。 Setting any of those will yield an error. 设置任何这些都会产生错误。 [...] [...]

Compared to html_document, it: 与html_document相比,它:

  • never uses retina figures 从不使用视网膜图形
  • never uses a theme 从不使用主题

However, a possible solution might be to switch from html_vignette to html_document : 但是,可能的解决方案可能是从html_vignette切换到html_document

output:
  html_document:
    toc: true
    toc_depth: 3
    toc_float: true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在R Bookdown(GitBook)中更改TOC深度? - How to change TOC depth in R Bookdown (GitBook)? Bookdown:带有html_document2的TOC - Bookdown: TOC with html_document2 R Bookdown - 自定义目录/侧边栏的宽度 - R Bookdown - Customize width of TOC/Sidebar 如何指定初始级别以将我的目录扩展到 R bookdown 项目(gitbook 输出格式)? 使用 YAML 设置? - How can I specific the initial level to have my table of contents be expanded to in an R bookdown project (gitbook output format)? With YAML setting? 如何在 bookdown 中添加参考书目/参考目录 - How to add bibliography/references to TOC in bookdown 如何让 webshot 与 bookdown 一起使用? - How can I get webshot to work with bookdown? 如何在 bookdown / knitr 文档中使用 R 函数生成脚注 URL 链接? - How can I generate footnote URL links with an R function in bookdown / knitr documents? CSS 和 R markdown(预订)。 如何在不更改整体模板的情况下使用 CSS 构建 css 盒子? - CSS and R markdown (bookdown). How can I use a CSS to build css boxes without changing the overall template? 如何以智能方式将图像从互联网插入到R bookdown生成的pdf文件中? - How can I insert an image from internet to the pdf file produced by R bookdown in a smart way? 如何在 R Bookdown 中呈现实际的 a6 纸张尺寸? - how do i render an actual a6 paper size in R Bookdown?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM