【发布时间】:2020-05-14 10:18:23
【问题描述】:
创建了下表,并希望在单元格的中心/中间垂直对齐单词“物种”。我正在使用RMarkdown 生成 HTML 而不是 LateX。有小费吗?
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE )
library( kableExtra )
options( scipen = 99 )
```
```{r iris}
tab_iris <- knitr::kable( iris , format = "html" , col.names = c( "Sepal<br>Length" , "Sepal<br>Width" , "Petal<br>Length" , "Petal<br>Width" , "Species" ) , align = "c" , escape = F ) %>% kable_styling(full_width = F , bootstrap_options = c( 'hover', 'condensed' , 'bordered'), position = 'left') %>% add_header_above( c('Kendal Iris Test' = 5) , bold = TRUE , background = '#0077c8' , color = 'white' )
```
`r tab_iris`
【问题讨论】:
-
这能回答你的问题吗? RMarkdown kable vertically align cells
-
@M——遗憾的是没有。需要使用 HTML 格式进行编辑,而不是 LateX。
-
kable( iris , format = "html" , col.names = c( "Sepal<br>Length" , "Sepal<br>Width" , "Petal<br>Length" , "Petal<br>Width" , "Species" ) , align = "c" , escape = F ) %>% kable_styling(full_width = F , bootstrap_options = c( 'hover', 'condensed' , 'bordered'), position = 'left') %>% add_header_above( c('Kendal Iris Test' = 5) , bold = TRUE , background = '#0077c8' , color = 'white' ) %>% kable_styling(full_width = T) %>% row_spec(0 , bold = T, extra_css = 'vertical-align: middle !important;')
标签: html r r-markdown knitr kableextra