[英]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? 有任何想法吗?
---
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
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.