latex - R Markdown pdf_document2 PDF图形和表格编号按部分
问题描述
我想pdf_document2
在 R Markdown 中生成一个 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)
```
解决方案
笨拙的解决方案是在标题中添加一些 LaTeX 命令:
header-includes:
\let\counterwithout\relax
\let\counterwithin\relax
\usepackage{chngcntr}
\counterwithin{figure}{section}
推荐阅读
- python - Using decorators with class
- c++ - const char* 作为参数传递时会自动删除吗?
- regex - Scala - 匹配非空字符串的正则表达式
- sql - 在 SQL 查询中,不能用这些名称减去具有给定名称的计算列
- vba - 如何忽略字符串 VBA Word 的所有拼写错误?
- ios - Smoothly speed up rotation in SwiftUI
- javascript - ChartJS, Multiple line in bar chart label
- c++ - How to have set of struct using custom comparator function instead of operator overloading
- user-interface - How do I add a shadow behind the tab bar in flutter?
- python - 寻找最有效路径的算法