简体   繁体   English

rmarkdown-导出目录

[英]rmarkdown - export table of contents

I have an RMarkdown file used for creating a QC report on other sets of data, and the report is relatively long. 我有一个RMarkdown文件,用于根据其他数据集创建质量控制报告,该报告相对较长。 My table of contents essentially contains the name of all the checks I run on the data, and I'd like to have the table of contents itself exported into a new document, for outside users to quickly see what checks are run. 我的目录实质上包含我对数据进行的所有检查的名称,并且我希望将目录本身导出到新文档中,以使外部用户可以快速查看正在执行的检查。

Is there any way to export just the TOC to word/pdf/html, or otherwise 'roll up' and export the different sections of an RMarkdown file? 有什么方法可以只将TOC导出到word / pdf / html,或者“卷起”并导出RMarkdown文件的不同部分?

I'm not entirely clear on what you're trying to achieve. 对于您要实现的目标,我还不太清楚。

Perhaps you're after a "floating" TOC, like this? 也许您正在像这样的“浮动”目录?

---
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)
```

在此处输入图片说明

For a html_document output format, you can set the body Pandoc variable to a void string: 对于html_document输出格式,可以将body Pandoc变量设置为空字符串:

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

This solution will not work for a pdf_document or a word_document . 该解决方案不适用于pdf_documentword_document

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM