【问题标题】:Why does toc_depth doesn't work with rmarkdown theme?为什么 toc_depth 不适用于 rmarkdown 主题?
【发布时间】:2021-12-28 15:07:06
【问题描述】:

我想用rmdformats 包中的downcute (chaos) 主题创建一个Rmarkdown html 报告。现在一切正常,除了我的yaml 标头中的toc_depth 参数。目录将只显示h1h2

install.packages("rmdformats")
---
title: "Title"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
  rmdformats::downcute:
    code_folding: hide
    toc_depth: 5
    self_contained: true
    thumbnails: false
    lightbox: true
    downcute_theme: "chaos"
pkgdown:
  as_is: true
---

# h1

## h2

### h3

#### h4

##### h5

【问题讨论】:

    标签: r r-markdown knitr


    【解决方案1】:

    不幸的是,rmdformats::downcute() 仅适用于开箱即用的 toc_depth 2 或更少。 rmdformats GitHub page 有很多问题,这里针对不同的主题进行了讨论。

    但是,根据this issue 的一个答案,您可以通过将其粘贴到 R Markdown 文件的开头来获得 toc_depth: 5

    <style>
    #toc ul.nav li ul li {
        display: none;
        max-height: none;
    }
    
    #toc ul.nav li.active ul li  {
        display: block;
        max-height: none;
    }
    
    #toc ul.nav li ul li ul li {
        max-height: none;
        display: none !important;
    }
    
    #toc ul.nav li ul li.active ul li {
        max-height: none;
        display: block !important;
    }
    </style>
    

    请注意,这会破坏目录的流畅动画。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-21
      • 1970-01-01
      • 2021-05-20
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2016-12-23
      • 1970-01-01
      相关资源
      最近更新 更多