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

时间:2019-01-10 02:49:01

标签: r r-markdown bookdown

我一直在研究ConnectorClient中的一份报告,该报告有些冗长,并且想用r-markdown分成几部分。我正在使用带有引导菜单栏的自定义html模板,该菜单栏在bookdown的前部启用,并带有:

yaml

我的可复制示例产生以下错误:

  

html_document中的错误(fig_width = fig_width,fig_height = fig_height,   :指定“ toc_float”选项时必须使用主题   调用:...->基本格式->输出格式->   html_document

当我包含toc: true toc_float: true 时,出现此错误:

  

html_document中的错误(fig_width = fig_width,fig_height = fig_height,   :正式参数“主题”与多个实际参数匹配   通话:... do.call->-> base_format->   output_format

该文档在没有theme: default的情况下进行编织,但是我的引导菜单栏消失了(如设计那样)。

有什么想法吗?

父文档:

toc_float

子文档:

---
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"}
```

1 个答案:

答案 0 :(得分:1)

如果我正确理解这一点,则toc_float无法与rmarkdown::html_vignette一起使用,因为您无法设置主题。

摘自rmarkdown::html_vignette的文档:

  

其他参数传递给html_document。请注意,主题,fig_retina和Highlight是硬编码的。设置任何这些都会产生错误。 [...]

     

与html_document相比,它:

     
      
  • 从不使用视网膜图形
  •   
  • 从不使用主题
  •   

但是,可能的解决方案可能是从html_vignette切换到html_document

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