为什么用点分隔的两位数的数字只显示在html_document2中?

Why figure numbers with two digits separated by dot are shown only in html_document2?

这是包含两个部分和两张图片的简单 RMarkdown 文档。

---
output:
  bookdown::html_document2: default
  bookdown::word_document2: default
  bookdown::pdf_document2: default
---

\newpage

# Part 1

Part 1 starts here. See Figure \@ref(fig:fig1-1) 

![(\#fig:fig1-1) expected to be Figure 1.1.](/usr/lib/rstudio/www/images/rstudio.png)

# Part 2

Part 2 starts here. See Figure \@ref(fig:fig2-1) 

![(\#fig:fig2-1) expected to be Figure 2.1.](/usr/lib/rstudio/www/images/rstudio.png)

我希望使用 Knit 渲染的两张图片的编号如下 - 第一张是 图 1.1,第二张是 图 2.1。但是我只在 html_document2 中得到这个渲染(见下图):

我使用最新的 RStudio 1.1.414 和 Git (38efc82) 的最新书本。 我在这里有两个问题:

  1. 为什么我的 Word 或 PDF 中没有图 1.1图 2.1
  2. 如何在 Word 或 PDF 中获取图 1.1图 2.1

我只能解决通过 LaTeX 输出 PDF 的问题。默认情况下,使用 LaTeX 文档类 article,它使用连续的图形编号。如果您的文档太长以至于在每个顶级部分中对数字进行编号是有意义的,那么您可能需要使用 reportbook 来代替,例如:

---
documentclass: book
output:
  bookdown::pdf_document2: default
  bookdown::word_document2: default
  bookdown::html_document2: default
---

或者,您可以使用一些 LaTeX 包来更改图形编号的格式,例如:

---
header-includes:
  \usepackage{chngcntr}
  \counterwithin{figure}{section}
output:
  bookdown::pdf_document2: default
  bookdown::word_document2: default
  bookdown::html_document2: default
---

另一种选择是来自 amsmath\numberwithin 命令,以防您仍然使用该软件包。