【问题标题】:rmarkdown - export table of contentsrmarkdown - 导出目录
【发布时间】:2019-02-21 23:35:30
【问题描述】:

我有一个 RMarkdown 文件,用于创建其他数据集的 QC 报告,报告比较长。我的目录本质上包含我对数据运行的所有检查的名称,我希望将目录本身导出到一个新文档中,以便外部用户快速查看正在运行的检查。

有什么方法可以只将 TOC 导出到 word/pdf/html,或者“汇总”并导出 RMarkdown 文件的不同部分?

【问题讨论】:

  • 我正在寻找类似的东西,您找到解决方案了吗?

标签: r r-markdown


【解决方案1】:

我并不完全清楚你想要达到的目标。

也许您正在寻找像这样的“浮动”目录?

---
title: "Title"
output:
  html_document:
    toc: true
    toc_float: true
---


# Section 1

```{r}
stringi::stri_rand_lipsum(4, start_lipsum = TRUE)
```

# Section 2

```{r}
stringi::stri_rand_lipsum(4, start_lipsum = TRUE)
```

【讨论】:

  • 我将问题编辑得更清楚 - 我只想将 TOC(在本例中为正在运行的 R 分析的名称)导出到某个外部文件。你知道这是否可能吗?
【解决方案2】:

对于html_document 输出格式,您可以将body Pandoc variable 设置为空字符串:

---
title: "Title"
output: 
  html_document:
    toc: true
    pandoc_args: ['-V', 'body=""']
---

此解决方案不适用于pdf_documentword_document

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-07
    • 2016-01-29
    • 2020-12-31
    • 1970-01-01
    • 1970-01-01
    • 2016-12-25
    • 2018-11-01
    • 2014-07-20
    相关资源
    最近更新 更多