rmarkdown生成的pdf文档中表格上的标题

rmarkdown生成的pdf文档中表格上的标题,r,knitr,r-markdown,xtable,R,Knitr,R Markdown,Xtable,如何在rmarkdown生成的pdf_文档中获取表格浮动上的标题 使用 及 生成带有myplot和指定标题的浮动图形 如何使用xtable生成的表实现同样的功能 ```{r, results='asis', fig.cap='table caption'} print(xtable(table), comment = FALSE) ``` 我曾尝试在print.xtable中使用floating.environment='figure',但没有任何效果。如果您仍在使用markdown,

如何在rmarkdown生成的pdf_文档中获取表格浮动上的标题

使用

生成带有myplot和指定标题的浮动图形

如何使用xtable生成的表实现同样的功能

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

我曾尝试在print.xtable中使用floating.environment='figure',但没有任何效果。

如果您仍在使用markdown,为什么不坚持使用相同的(简单而漂亮的)格式呢。快速示例:

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

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

Table: foo
或者类似地

```{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)
```
```{r results='asis'}
knitr::kable(head(mtcars), format = 'pandoc', caption = 'Title of the table')
```
```{r, results='asis'}
print(xtable(table, caption='Captions goes within xtable'), comment = FALSE)
```