我知道如何缩进文本,例如项目符号和数字列表,但我还想缩进编号的章节和子章节。 给定以下代码,它呈现为代码后面的屏幕截图。目录有子标题缩进,我也想缩进内容正文。
是否有一种方法也可以缩进文档正文中的子标题?请参见之后的Desired Output Example
项。
---
title: "R Markdown Example With Numbered Sections"
output:
bookdown::pdf_document2:
toc: true
toc_depth: 6
number_sections: true
---
# Section A
## Level 2 A
### Level 3 A
#### Level 4 A
## Level 2 A
# Section B
## Level 2 B
未嵌套子节渲染
所需输出示例
... table of contents as above ...
1 Section A
1.1 Level 2 A
1.1.1 Level 3 A
1.1.1.1 Level 4 A
1.2 Level 2 A
2 Section B
2.1 Level 2 B
编辑:2021-12-15
这个由 @Peter 提供的解决方法在我的 Mac 上有效,但我正在使用的 Linux 系统需要一种变通方法。我发现解决方案在我的 Linux 机器上无法工作是由于我所拥有的 titlesec
版本2.10存在一个错误。修复方法可以是更新 titlesec
或使用一个变通方法;这两种方法都在此链接中描述:titlesec: loss of section numbering with the new update (2016/03/15)