I would like to use kable() and some of the functions in the kableExtra package to display a table that includes different math type (table of laboratory values with different metrics) in a pdf report. However, if I'm using some of the functions in the kableExtra package, the math styling is lost. For example:
library(knitr)
library(kableExtra)
k <- mtcars[c(1:5), c(1:5)]
k[3,3] <- '$\\mu$mm$^3$'
kable(k, escape = TRUE)
Works as expected:
But if I add in some extra styling, such as add_indent, the math symbols are no longer preserved.
kable(k, escape = TRUE) %>%
add_indent(3)
EDIT: I've tried both with escape=TRUE and escape=FALSE, and neither produces the desired output.
Results in:
Any help is appreciated. Thanks!


I would try to use cat and
result: asis: