我正在使用 RMarkdown 中的 KnitR HTML 生成 HTML 页面(使用 R Studio)。
我需要从任意数字开始的节编号,而不是 0 或 1。
我想要实现的目标的示例:
TITLE
2 SECTION
2.1 SUB-SECTION
我使用的代码如下:
---
title: "TITLE"
output:
html_document:
number_sections: yes
---
# SECTION
## SUBSECTION
最佳答案
我在 this question 中找到了以下内容.
pandoc
选项--number-offset
允许指定“HTML 输出中节标题的偏移量”:
--number-offset=NUMBER[,NUMBER,…]
Offset for section headings in HTML output (ignored in other output formats). The first number is added to the section number for top-level headers, the second for second-level headers, and so on. So, for example, if you want the first top-level header in your document to be numbered “6”, specify
--number-offset=5
. If your document starts with a level-2 header which you want to be numbered “1.5”, specify--number-offset=1,4
. Offsets are 0 by default. Implies--number-sections
.
关于knitr - RMarkdown 与 Knit to HTML : How to increase section number?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33707491/