本文介绍了由rmarkdown生成的pdf文档中表格的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取由rmarkdown生成的pdf_document中的表格浮动标题?

How can I get captions on my table floats in pdf_document generated by rmarkdown?

使用

output:
  pdf_document:
    fig_caption: true

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

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

Generates a floating figure with myplot and the caption specified.

如何使用xtable生成的表实现相同的目的?

How do I achieve the same thing with tables generated by xtable?

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

我尝试在print.xtable中使用float.environment ='figure',但无济于事.

I have tried using floating.environment = 'figure' in print.xtable, but to no avail.

推荐答案

标题"是xtable的参数,而不是print.xtable

The 'caption' is a parameter to xtable, not to print.xtable

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

这篇关于由rmarkdown生成的pdf文档中表格的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 03:50