3

I'd like for my font size in the footnotes to be smaller than the text in the table, but can't figure it out. Is there something similar to kable_styling where I can edit the text and color of rows in the table that can be used for footnotes? I am using RMarkdown to generate the HTML not LateX.

enter image description here

---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE )

library( kableExtra )
library( knitr ) 

```

```{r mtcars}

 tab_mtcars <- knitr::kable( mtcars[ 1:5 , c( 1:4 )] , format = "html", col.names = c( "MPG", "CYL", "DISP" , "HP" ) ,  align = "lccc" , escape = F ) %>% kable_styling( full_width = T , bootstrap_options = c( "hover", "condensed" , "bordered"), position = "left") %>% add_header_above( c( "mtcars example" = 5 ) , bold = TRUE ) %>% footnote( general = c( "Here is the footnote where I would like font smaller than above" ),     general_title = "Note: ", footnote_as_chunk = T )

```

`r tab_mtcars`
kendalorgera
  • 147
  • 2
  • 11

2 Answers2

7

You could use the html <small> tag in the text for the general and general_title parameters of the kabaleExtra::footnote function. See example:

tab_mtcars <-
  knitr::kable(
    mtcars[1:5 , c(1:4)] ,
    format = "html",
    col.names = c("MPG", "CYL", "DISP" , "HP") ,
    align = "lccc" ,
    escape = F
  ) %>%
  kable_styling(
    full_width = T ,
    bootstrap_options = c("hover", "condensed" , "bordered"),
    position = "left"
  ) %>% add_header_above(c("mtcars example" = 5) , bold = TRUE) %>% footnote(
    general = c(
      "<small>Here is the footnote where I would like font smaller than above</small>"
    ),
    general_title = "<small>Note: </small>",
    footnote_as_chunk = T ,
    escape = F
  )
W. Joel Schneider
  • 1,711
  • 13
  • 14
1

There doesn't seem to be a way to control that from kable() that I can see, so you could change the CSS styling. With your YAML as the following:

---
title: "Untitled"
output:
  html_document:
    css: style.css
---

and a style.css file in the same folder containing some css code:

tfoot {
  font-size: 80%;
}

enter image description here

joshpk
  • 729
  • 4
  • 11
  • This will likely force the entire document into CSS styling, right? So I'd have to create this table in a separate file then import it into the main markdown report file? – kendalorgera Feb 11 '20 at 22:55
  • I'm not sure what you mean - this would change the footnote size for all tables in the document. Do you only want this change for a particular table? – joshpk Feb 12 '20 at 15:41
  • For whatever reason it's not allowing me to use style.css. But I was concerned that it would impact the HTML code I used throughout. It's a 1000 line document with state parameters and only a few of the tables need smaller footnotes. – kendalorgera Feb 13 '20 at 17:53