【发布时间】:2020-05-20 18:37:00
【问题描述】:
我正在 RStudio 中尝试使用 Knitr/KableExtra,但无法让我的表格使用网络浏览器的全宽或控制屏幕上的表格对齐方式。
下面是代码示例,根据 kable_styling 文档,我尝试强制表格与屏幕左侧对齐,但在 html 输出中,表格始终居中。它看到左侧有一个我无法使用的不可见边距。当我有一个包含更多字段的表格时,就会出现问题......左侧的大边距仍然存在,迫使表格延伸到屏幕右侧并生成一个水平滚动条 - 非常烦人和丑陋。
有什么方法可以使用左边距或强制表格真正向左对齐?
这是一个问题的例子:
---
title: "Untitled"
author: "ME"
date: "2/4/2020"
output: html_document
---
```{r setup, include=FALSE}
library(kableExtra)
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
x_html <- knitr::kable(head(mtcars), "html")
kable_styling(x_html, "striped", position = "left", font_size = 7)
```
【问题讨论】:
标签: r knitr kable kableextra