You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使R Markdown页面左侧面板的副标题可见?

解决R Markdown左侧面板副标题不显示的问题

问题原因

你配置里的toc_depth参数设为了1,这意味着左侧目录只渲染一级标题(#),二级(##)、三级(###)标题不会被纳入目录范围。

解决方法

修改html_document和pdf_document下的toc_depth值,设置为你需要显示的标题层级:

  • 要显示二级标题(##),将值设为2
  • 要显示三级标题(###),将值设为3

修改后的完整YAML配置如下:

---
title: ""
output:
  html_document:
    theme: flatly
    highlight: tango
    toc: yes
    toc_float: yes
    collapsed: no
    number_sections: no
    toc_depth: 2  # 改为2可显示一级+二级标题;需显示三级则设为3
  pdf_document:
    toc: yes
    toc_depth: 2  # 同步修改PDF输出的配置,保持目录层级一致
---

效果验证

重新渲染文档后,左侧浮动目录会自动显示## R Markdown Sub title这类副标题;若将toc_depth设为3,还会进一步显示### R Markdown Sub Sub title。

内容的提问来源于stack exchange,提问作者symkly

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 02:08:17