2017-03-17 77 views
0
--- 
title: '1' 
author: '1' 
date: "March 16, 2017" 
output: 
    pdf_document: default 
--- 

```{r cars} 
library(pander) 
pander(mtcars, split.cells = 5, split.table = Inf, 
     caption = "A long long long long long long long long long long 
       too long long long long long long long long caption") 
``` 


```{r} 
library(pander) 
pander(mtcars, split.cells = 5, split.table = Inf, 
     caption = paste("A long long long long long long long long long long", 
       "too long long long long long long long long caption", 
       collapse = "\n")) 
``` 

enter image description here如何編織rmarkdown PDF

我試圖粘貼功能與崩潰=「\ n」,但它失敗時包的標題中的R奉迎功能。我希望(1)有一個標題,在「太」字之前換行,(2)也將標題居中,而不是將標題對齊到左側。

回答

0

稍微笨拙的方法是手動調整標題頁邊距,以便標題打破您希望它打破的位置。在您的YAML標題中包含\usepackage{caption},然後在表格之前設置標題邊距。如果您不希望標題以相同的方式打破,則需要在下一張表或數字之前將其重置。

--- 
title: '1' 
author: '1' 
date: "March 16, 2017" 
output: 
    pdf_document: 
    keep_tex: true 
header-includes: 
    - \usepackage{caption} 
--- 

\captionsetup{justification=centering,margin=3.5cm} 
```{r} 
library(pander) 
pander(head(mtcars), split.cells = 5, split.table = Inf, 
     caption = "A long long long long long long long long long long too long long 
     long long long long long long caption") 
``` 

輸出:

enter image description here

相關問題