为什么用点分隔的两位数的数字只显示在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)

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

我希望使用 Knit 渲染的两张图片的编号如下 - 第一张是 图 1.1,第二张是 图 2.1。但是我只在 html_document2
中得到这个渲染(见下图):
我使用最新的 RStudio 1.1.414 和 Git (38efc82) 的最新书本。
我在这里有两个问题:
- 为什么我的 Word 或 PDF 中没有图 1.1 和 图 2.1?
- 如何在 Word 或 PDF 中获取图 1.1 和 图 2.1?
我只能解决通过 LaTeX 输出 PDF 的问题。默认情况下,使用 LaTeX 文档类 article
,它使用连续的图形编号。如果您的文档太长以至于在每个顶级部分中对数字进行编号是有意义的,那么您可能需要使用 report
或 book
来代替,例如:
---
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
命令,以防您仍然使用该软件包。
这是包含两个部分和两张图片的简单 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)

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

我希望使用 Knit 渲染的两张图片的编号如下 - 第一张是 图 1.1,第二张是 图 2.1。但是我只在 html_document2
中得到这个渲染(见下图):
我使用最新的 RStudio 1.1.414 和 Git (38efc82) 的最新书本。 我在这里有两个问题:
- 为什么我的 Word 或 PDF 中没有图 1.1 和 图 2.1?
- 如何在 Word 或 PDF 中获取图 1.1 和 图 2.1?
我只能解决通过 LaTeX 输出 PDF 的问题。默认情况下,使用 LaTeX 文档类 article
,它使用连续的图形编号。如果您的文档太长以至于在每个顶级部分中对数字进行编号是有意义的,那么您可能需要使用 report
或 book
来代替,例如:
---
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
命令,以防您仍然使用该软件包。