简体   繁体   English

使用rmarkdown在左侧显示大纲/目录,在右侧显示内容

[英]outline/toc on the left and contents on the right layout using rmarkdown

I was checking out how to include a nice table of contents / document outline in my rmarkdown document (with html output). 我正在检查如何在我的rmarkdown文档(包括html输出)中包含漂亮的目录/文档大纲。

Well, the "standard" approach: 好吧,“标准”方法:

html_document:
    toc: true

It works, but I do not like it (not even tweaking options and themes). 它有效,但我不喜欢它(甚至不调整选项和主题)。

But actually, in several pages of the documentation (eg http://rmarkdown.rstudio.com/html_document_format.html ), they use a very nice layout that includes a table of contents / document outline to the left of the page and the contents of the right (and the outline syncs with the contents part, Highlighting where on the contents you currenly are). 但是实际上,在文档的几页中(例如, http : //rmarkdown.rstudio.com/html_document_format.html ),他们使用了非常不错的布局,其中包括目录/文档大纲(位于页面左侧)和目录的内容右边的(轮廓与内容部分同步,突出显示您当前在内容上的位置)。

This is EXACTLY what I want. 这正是我想要的。 And I guess they did it using rmarkdown . 而且我猜他们是使用rmarkdown But I cannot find how to do it. 但是我找不到怎么做。

I've check that documentation page, as well as rmarkdown gallery , flex dashboard , web sites among others. 我已经检查了该文档页面,以及rmarkdown 画廊flex仪表板网站等。 But I can't seem to figure it out how to do it. 但我似乎无法弄清楚该如何做。

Well, using web sites I would be able to do it, but it seems overly complicated for what I want (you need to have several pages, and at least index.Rmd file and the _site.yml file). 好了,使用网站我可以做到,但是对于我想要的东西来说似乎太过复杂了(您需要有多个页面,至少需要index.Rmd文件和_site.yml文件)。

Instead, I guess there should be an option to simply tell rmarkdown to take my single document and put the section headers in a nice frame to the left, as in the example page from RStudio. 相反,我猜应该有一个选项可以简单地告诉rmarkdown接收我的单个文档,并将节标题放在左侧的漂亮框中,如RStudio的示例页中所示。

Have you tried this approach? 您是否尝试过这种方法? It works for me and it's also on the homepage, you provided: 它对我有用,并且也在您提供的主页上:

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

# header 1
# header 2
# header 3

With a little bit of text, it looks like that: 加上一些文字,看起来像这样:

在此处输入图片说明

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

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