unable to render superscript in column name in tibble in Quarto #5977
-
DescriptionHi, when I am rendering the html output with Quarto, I found the superscript in a column name in a tibble displayed as a plain string. However, when running in Rscript the same code shows the superscript correctly. I think it is due to some setting I missed for telling the r chunk to parse as r expression, but I always get the plain string whatever methods I tried. The R script code is: And the code in r chunk in Quarto is:
The Quarto version I am using is 1.3.361, and I already set the engine: knitr in the YAML front matter. Many thanks in advance!! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Could you share a small self-contained "working" (reproducible) example to work with, i.e., a complete Quarto document or a Git repository? Thanks. You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````qmd
---
title: "Reproducible Quarto Document"
format: html
---
This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.
```{r}
plot(cars)
```
The end.
```` |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi there, This is more of a knitr question than Quarto. Since you are rendering in html output, knitr is by default trying to print an html-format table. That is, knitr is expecting html tags for formatting and instead you are feeding latex code. So, in the language of html, changing the
Don't forget to include ---
engine: knitr
title: "test_table"
format: html
---
## Running Code
```{r}
#| warning: false
#| code-fold: true
library(tidyverse)
library(kableExtra)
test_table <- data.frame(
Column1 = rnorm(1),
Column2 = rnorm(1),
Column3 = rnorm(1),
Column4 = rnorm(1)
)
test_table %>%
as_tibble() %>%
kbl(col.names = c("Type", "Frequency", "PMI", "(Signed G<sup>2</sup>)"), escape = FALSE) %>%
kable_minimal() %>%
scroll_box(height = "400px")
```
The end. Alternatively you can simply change the table format in |
Beta Was this translation helpful? Give feedback.
Hi there,
This is more of a knitr question than Quarto. Since you are rendering in html output, knitr is by default trying to print an html-format table. That is, knitr is expecting html tags for formatting and instead you are feeding latex code. So, in the language of html, changing the
kbl()
function call to the following should have your desired effect:Don't forget to include
escape = FALSE
. Full.qmd
example: