2017-03-17 136 views
4

我有以下Rmarkdown(.Rmd)文档,我将其称为现有的.png图像并创建带有标题的.pdf。默认情况下,pandoc?正在自动添加“图#”。在每张照片的标题之前。我可以看到这将是正常的事情,但在我的情况下,我想定义这一点。我发现这个主题的变化,但似乎没有找到解决办法。下面是我的.Rmd文件的外观的例子:如何在Rmarkdown中禁止自动图形编号/ pandoc

--- 
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) 
+0

是否要删除或编辑编号? – ErrantBard

+0

我想完全删除编号。 –

+0

所以你只是想要“图:标题为图1”或绝对没有标题? –

回答

7

你可以使用带字幕包

创建您指定下列一个.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) 
+2

刚刚发现YourName.tex的行可以直接放在起始行: 'header-includes: \ usepackage {caption} \ captionsetup [figure] {labelformat = empty}' –

+0

@Marcinthebox很好!在大多数我自己的报告中,我都会做一些非默认的乳胶,但在那些时候,你只是使用奇怪的包装而已,简单得多 – ErrantBard

相关问题