R / shiny + mathjax not displaying math

I have strange behavior with MathJaxand shiny. I changed the example 01_hellofrom the package shinyto add the file .Rmdthrough includeMarkdown(). All I changed was ui.Ras follows:

# Show a plot of the generated distribution
mainPanel(
  plotOutput("distPlot"),
  includeMarkdown("mathjax-test.Rmd")
)

The content of my test file ( mathjax-test.Rmd) looks like this:

## mathjax test

Document used as is in .Rmd format.

Here an inline equation with dollar signs: $a + b = c$

Here an inline equation with slashes/parentheses: \(a + b = c\)

Display format wth double dollar signs:

$$a + b = c$$

Display format with slashes/square brackets:

\[
a + b = c
\]

When I knit a file .Rmd, I get the expected results:

knit-rmd

When I use runApp(), I get the following:

shiny rmd


Things I tried:

  • adding withMathJax()after titlePanelin ui.Rfor this RStudio page
  • wrapping includeMarkdown()insidewithMathJax()
  • put library(shiny)and withMathJax()in the code block at the top of the file.Rmd
  • , , includeMarkdown() mainPanel ui.R:

tags$script(src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML")

, ! <head> shiny :

  <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>

?

+4

Source: https://habr.com/ru/post/1658271/


All Articles