簡體   English   中英

rmarkdown生成的pdf文檔中表格的標題

[英]Captions on tables in pdf documents generated by rmarkdown

如何在rmarkdown生成的pdf_document中獲取我的表浮動的標題?

運用

output:
  pdf_document:
    fig_caption: true

```{r, fig.cap='a caption'} 
myplot 
```

使用myplot和指定的標題生成浮動數字。

如何使用xtable生成的表實現相同的功能?

```{r, results='asis', fig.cap='table caption'}
    print(xtable(table), comment = FALSE)
```

我曾嘗試在print.xtable中使用floating.environment ='figure',但無濟於事。

或者類似地,

```{r results='asis'}
knitr::kable(head(mtcars), format = 'pandoc', caption = 'Title of the table')
```

'caption'是xtable的參數,而不是print.xtable

```{r, results='asis'}
print(xtable(table, caption='Captions goes within xtable'), comment = FALSE)
```

如果你正在使用markdown,為什么不堅持使用相同(簡單和漂亮)的格式。 快速舉例:

> library(pander)
> pander(table(mtcars$am), caption = 'foo')

-------
 0   1 
--- ---
19  13 
-------

Table: foo

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM