我正在使用xtable
在 HTML 文档中创建一个表格,我遇到rmarkdown
的问题是输出表格向左对齐,我需要它居中。我试过kable
包装,但桌子太宽了。问题是是否有办法将 HTML 文档中的表格居中,类似于fig.aling = 'center'
but 对于不需要LaTex
.
从在 R 中格式化 html 表中获得灵感,您可以使用 的html.table.attributes
参数添加表属性print.xtable
。
例如:
```{r, results='asis'}
library(xtable)
print(
xtable(mtcars[1:2, 1:4], align="lcccc"), # align columns
type = "html",
html.table.attributes = 'align="center", # center table in page
rules="rows", # only keep horizontal rows
width=50%, # increase table width to 50% page
frame="below"') # remove border except bottom rule
```
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句