I am printing a table that contains _ characters with kable() in a quarto file using an HTML output and it is italicizing and/or bolding the output rather than printing the _ characters. How can I print the output as is rather than converting it into italicized and/or bolded text?
I messed around with
#| output: asis
and it just further messed up the formatting.
You can see the problem if you render this:
```{r}
blah <- data.frame(word = c("abcde", "a_c_e", "_b___", "__c__"))
blah |>
knitr::kable()
```
You could use the following trick: add the parse-latex filter and render the kable to LaTeX, i.e.
---
title: "Untitled"
format: html
filters: [parse-latex.lua]
---
```{r}
blah <- data.frame(word = c("abcde", "a_c_e", "_b___", "__c__"))
```
```{r}
#| layout-ncol: 2
#| tbl-subcap: ["HTML table", "LaTeX table"]
blah |>
knitr::kable()
blah |>
knitr::kable(format = "latex")
```
Result: