knitr - RMarkdown 与 Knit to HTML : How to increase section number?

标签 knitr r-markdown

我正在使用 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.

引自pandoc README file .

关于knitr - RMarkdown 与 Knit to HTML : How to increase section number?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33707491/

相关文章:

latex - 为 rmarkdown PDF 中的每一行文本编号

rstudio - 使用 Reveal.js 将标题幻灯片图像添加到 RMarkdown 幻灯片

r-markdown - 爱思唯尔文章未正确呈现从属关系

r - 将 MATLAB 脚本集成到 R Markdown 文档中

r - 在 R markdown 中创建括号内的文本(在项目符号列表中)

RMarkdown、R 笔记本和内存管理

r - inline::cxxfunction 在 knitr 中显示不佳

r - 是否可以使用Rstudio在不使用Pandoc的情况下直接将.Rmd转换为LaTeX?

r - 将向量分配给 data.table 列时出现打印错误

r - 更改 rmarkdown "table of contents"默认标题