R/shiny + mathjax, not rendering math

喜欢而已 提交于 2019-12-10 16:59:34

问题


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() after titlePanel in ui.R per this RStudio page
  • wrapping includeMarkdown() inside of withMathJax()
  • putting library(shiny) and withMathJax() in a code block at the top of the .Rmd file
  • adding the following first, right before, and right after includeMarkdown() in the mainPanel section of ui.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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!