I’m writing a shiny app that includes \cancel in the MathJax. I can’t figure out how to get it to work. Based on the link below, I guess I have to load the cancel TeX extension but I can’t figure out how.
library(shiny)
ui <- fluidPage(
withMathJax(),
div("$$1+2=3$$"), #Works
div("$$\\cancel{10a}$$") #Doesnt work
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
>Solution :
library(shiny)
js <- "
window.MathJax = {
loader: {load: ['[tex]/cancel']},
tex: {packages: {'[+]': ['cancel']}}
};
"
ui <- fluidPage(
tags$head(
tags$script(async="", src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"),
tags$script(HTML(js))
),
div("$$1+2=3$$"),
div("$$\\cancel{10a}$$")
)
server <- function(input, output, session) {}
shinyApp(ui, server)

