问题
I'm having odd behavior with MathJax and shiny. I've modified the 01_hello example from the shiny package to include a .Rmd file via includeMarkdown(). All I modified was ui.R to be as follows:
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot"),
includeMarkdown("mathjax-test.Rmd")
)
The contents of my test file (mathjax-test.Rmd) are like so:
## mathjax test
Document used as is in .Rmd format.
Here's an inline equation with dollar signs: $a + b = c$
Here's 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 the .Rmd file, I get the expected results:
When I use runApp() I get this:
Things I've tried:
- adding
withMathJax()aftertitlePanelinui.Rper this RStudio page - wrapping
includeMarkdown()inside ofwithMathJax() - putting
library(shiny)andwithMathJax()in a code block at the top of the.Rmdfile - adding the following first, right before, and right after
includeMarkdown()in themainPanelsection ofui.R:
tags$script(src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML")
I have no idea what's going on! I get this in the <head> of the shiny app page when I view the source:
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
What am I doing wrong?
来源:https://stackoverflow.com/questions/40143012/r-shiny-mathjax-not-rendering-math