我想在R Markdown中生成一个pdf_document2
PDF文档,其中的表格和图形根据其部分编号进行标记。例如,第2节中的第一个图将是图2.1。我可以使用html_document2
来做到这一点,但不能使用pdf_document2
来做到这一点。
有关我编写的代码,请参见下文。现在,代码将生成连续的图形编号(图1、2、3、4),而不是图1.1、1.2、2.1、2.2。
title: "Testing Section Numbers"
author: "Authors"
date: "January 2019"
output:
bookdown::pdf_document2:
fig_caption: yes
latex_engine: xelatex
number_sections: true
toc: yes
toc_depth: 2
editor_options:
chunk_output_type: console
link-citations: yes
linkcolor: blue
subparagraph: yes
citecolor: blue
urlcolor: blue
---
# R Markdown
```{r pressure1, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```
```{r pressure2, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```
# Including Plots
You can also embed plots, for example:
```{r pressure3, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```
```{r pressure4, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```
答案 0 :(得分:1)
笨拙的解决方案是在标头中添加一些LaTeX命令:
header-includes:
\let\counterwithout\relax
\let\counterwithin\relax
\usepackage{chngcntr}
\counterwithin{figure}{section}