library(knitr)
library(tidyverse)
tab <- tibble(
text = c("alpha"),
symbol = c("$\\alpha$")
)Math in kableExtra HTML tables
I want to output math in {kableExtra} HTML tables in a Quarto document. I can do it but have to use cat(). However if I use cat() I can’t cross reference. Any ideas? gist here. Output here.
kable() has both but none of the cool features of {kableExtra} (see Table 1). I also have to do this before loading {kableExtra}, otherwise it doesn’t work (I guess loading {kableExtra} forces HTML table output?)
kable(tab)| text | symbol |
|---|---|
| alpha | \(\alpha\) |
See Table 2, cross referencing works but math doesn’t.
library(kableExtra)
kbl(tab) %>%
kable_classic_2(html_font = "Arial")| text | symbol |
|---|---|
| alpha | $\alpha$ |
In ?@tbl-test2 math works but cross-referencing doesn’t:
kbl(tab) %>%
kable_classic_2(html_font = "Arial") %>%
cat()Test table 2
|
text
|
symbol
|
|---|---|
|
alpha
|
\(\alpha\)
|