[英]How to suppress automatic figure numbering in Rmarkdown / pandoc
我有以下Rmarkdown(.Rmd)文档,我调用现有的.png图像并创建带有标题的.pdf。 默认情况下,pandoc? 自动添加“图#”。 在每张图片的标题之前。 我可以看到这是正常的做法,但在我的情况下,我想定义这个。 我发现了这个主题的变化,但似乎没有找到解决方案。 下面是我的.Rmd文件的示例:
---
title: "TITLE"
author: "ME"
date: "`r Sys.Date()`"
output:
pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
![Caption for figure 1](figures/plot1.png)
\newpage
![Caption for figure 2](figures/plot2.png)
你可以使用caption-package
创建一个指定以下内容的.tex文件,下面将删除整个标签,您可以自由地对标签进行硬编码。
\usepackage{caption}
\captionsetup[figure]{labelformat=empty}
那你的.rmd应该是这样的:
---
title: "TITLE"
author: "ME"
date: "`r Sys.Date()`"
output:
pdf_document:
includes:
in_header: YourName.tex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
![Caption for figure 1](figures/plot1.png)
\newpage
![Caption for figure 2](figures/plot2.png)
简化:正如评论中所建议的那样,我们可以在.Rmd
文件中实现这一点,如下所示。
---
title: "TITLE"
author: "ME"
date: "`r Sys.Date()`"
output:
pdf_document:
header-includes:
- \usepackage{caption}
- \captionsetup[figure]{labelformat=empty}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
![Caption for figure 1](figures/plot1.png)
\newpage
![Caption for figure 2](figures/plot2.png)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.