Rmarkdown中的输出表宽度 [英] Output table width in Rmarkdown

查看:81
本文介绍了Rmarkdown中的输出表宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Rmarkdown创建文档.我想包括降价表,但它们都按比例缩放到页面的宽度.我想指定一个相对宽度,例如...表的40%.我尝试了与以下内容相关的各种选项:

I'm using Rmarkdown to create a document. I want to include markdown tables, but they are all scaled to the width of the page. I'd like to specify a relative width of say... 40% for the table. I've tried various options associated with the following:

library(pander)
pandoc.table(head(cars))

library(xtable)
print(xtable(head(cars)), type="html")

library(knitr)
kable( head(cars), format="markdown")

有什么想法吗?

谢谢

推荐答案

如果要输出html文档,则需要修改css.您可以将其直接添加到Rmd文档中:

If you're outputting an html document you need to modify the css. You can add this directly to the Rmd document:

<style type="text/css">
.table {

    width: 40%;

}
</style>

这篇关于Rmarkdown中的输出表宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆