-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Math rendering with Quarto and html #1822
Comments
Thanks for the report! It works correctly for me if I remove https://quarto.org/docs/authoring/tables.html#disabling-quarto-table-processing ---
format: html
---
```{r}
library(gt)
library(tidyverse)
head(mtcars) |>
gt() |>
tab_header(md('**mtcars** dataset'),
md('Testing a math formula: $e^{i \\pi}+1 = 0$'))
``` Since you may need to disable processing for some tables, but not for others, I suggest you use it as a chunk option. Or i.e. ---
format: html
---
```{r}
library(gt)
library(tidyverse)
head(mtcars) |>
gt() |>
tab_header(md('**mtcars** dataset'),
md('Testing a math formula: $e^{i \\pi}+1 = 0$'))
```
```{r}
#| html-table-processing: none
gt(mtcars)
``` |
More context on this. In this example: ---
output: html
html-table-processing: none
keep-md: true
---
```{r}
library(gt)
library(tidyverse)
head(mtcars) |>
gt() |>
tab_header(md('**mtcars** dataset'),
md('Testing a math formula: $e^{i \\pi}+1 = 0$'))
``` The equation is not showing correctly because I believe the Math libraries are not correctly inserted / loaded in the output document. In this case, gt is handling the math (as explained https://gt.rstudio.com/reference/fmt_markdown.html?q=math#examples) but then the JS libraries are not passed through as HTML dependencies probably. It means gt rely on quarto to load the right math library. This will happens if math are used elsewhere in the document (processed by Quarto) For example
Maybe this is an "accident" (@rich-iannone are you using katex or mathjax for math rendering ? ) Regarding
Honestly, @rich-iannone maybe this can be improve by setting right HTML dependencies through knitr. This is using katex right ? |
@cderv you are right in that we are using the katex package to perform math rendering. We can definitely improve this in more situations! |
So it means your are doing server side rendering (I mean in R directly), and then it requires some dependencies to be available ? I wonder why it is not working - my guess is html dependencies missing. Are you passing them through knitr ? |
Prework
Description
Math equations in gt headings and subheading are not displaying properly when rendering qmd files to html.
Reproducible example
The following is in a .qmd file:
Expected result
The math formula$e^{i \pi}+1 = 0$ should display nicely (LaTeX-style) in the table subheading. When running the code interactively in RStudio everything looks good in the viewer, but when rendering the .qmd file to .html it does not work.
Screenshot from RStudio viewer:
Screenshot from rendered html:
Session info
My Quarto version is 1.5.56 (from running
quarto --version
in the Terminal) and my RStudio version is 2024.04.0+735.The text was updated successfully, but these errors were encountered: