【问题标题】:In R & rmdformats, how can I control the width of kableExtra table?在 R & rmdformats 中,如何控制 kableExtra 表的宽度?
【发布时间】:2022-01-13 05:13:22
【问题描述】:

我正在寻找一种解决方案,使我能够控制rmdformats 文档中kableExtra 表的输出。

像这样的运行示例,我得到一个底部带有水平滚动条的表格。

---
output:
  rmdformats::robobook:
    code_folding: show
    self_contained: true
    highlight: pygments
editor_options: 
  chunk_output_type: console
---

```{r}
library(kableExtra)
dt <- cbind(mtcars[1:5, 1:6],mtcars[1:5, 1:6])
```

```{r}
dt %>%
  kbl() %>%
  kable_styling()
```

这不适用于较大的桌子,并且周围空间很大,我想增加桌子的宽度。

我尝试修改 knitr 块选项,但这似乎只影响数字。 rmdformats 选项也是如此。需要一些css吗?

【问题讨论】:

    标签: css r-markdown knitr kableextra


    【解决方案1】:

    herehere 的答案指向 css 解决方案,该解决方案通过在 YAML 下添加此部分来工作

    <style type="text/css">
    div.page-inner {
      max-width: 10000px !important;
    }
    </style>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-18
      • 2018-05-19
      • 1970-01-01
      • 2015-11-15
      • 2011-02-23
      • 1970-01-01
      • 2017-04-26
      相关资源
      最近更新 更多