2017-03-17 132 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

相關問題