简体   繁体   中英

Change the size of a title in KableExtra?

I have tried many techniques (mostly around editing the raw HTML passed to caption in order to change the size of a title ( aka caption ) when using KableExtra.

Minimal Reproducible Example

Here's a simple example:

library(knitr)
library(kableExtra)

iris %>%
  head %>%
  kable(
    table.attr = "style = \"color: black;\"", 
    caption = "<span style='font-size:20'>A lovely title</span>"
    ) %>%
  kable_styling("striped", full_width = T) 

But the title size doesn't change:

在此处输入图像描述

Span accepts CSS font-size in 3 different ways. Run the following examples to see them in action:

Pixels

library(knitr)
library(kableExtra)


iris %>% 
  head %>% 
  kable(
    table.attr = "style = \"color: black;\"", 
    caption = "<span style='font-size:20px'>A lovely title</span>"
    ) %>% 
  kable_styling("striped", full_width = T) 

Percent

iris %>% 
  head %>% 
  kable(
    table.attr = "style = \"color: black;\"", 
    caption = "<span style='font-size:200%'>A lovely title</span>"
    ) %>% 
  kable_styling("striped", full_width = T) 

"small", "large" etc.

iris %>% 
  head %>% 
  kable(
    table.attr = "style = \"color: black;\"", 
    caption = "<span style='font-size:small'>A lovely title</span>"
    ) %>% 
  kable_styling("striped", full_width = T) 

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM