【问题标题】:RMarkdown: Accordion the table of contents via CSSRMarkdown:通过 CSS 折叠目录
【发布时间】:2018-11-01 23:53:26
【问题描述】:

我有一个 Rmarkdown 文档,左侧有一个目录 (TOC)。

rmd 文件有一个 YAML 头:

---
title: "Foo"
author: "Bar"
date: "`r format(Sys.time(), '%d-%B-%Y')`"
output: 
  html_document:
    css: bam.css
    theme: flatly
    toc: true
---

这是完整的 bam.css:

#TOC {
  position: fixed;
  left: 10px;
  top: 10px;
  width: 200px;
  height: 100%;
  overflow:auto;
}

#TOC::before {
  content: "";
}

body {
  max-width: 800px;
  margin: auto;
  margin-left:230px;
  line-height: 20px;
}

有没有一种简单的方法来修改这个 CSS 以便 TOC 折叠?

【问题讨论】:

    标签: css r-markdown


    【解决方案1】:

    我发现最简单的方法是通过 YAML 标头中的toc_float。例如:

     output: 
      html_document:
        theme: flatly
        toc: true
        toc_float: true
    

    【讨论】:

      猜你喜欢
      • 2010-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-07
      • 1970-01-01
      • 1970-01-01
      • 2012-12-31
      相关资源
      最近更新 更多