A solution to display LaTeX equations in line is offered here with a working live demo
The above mentioned solution to display equations in line is (cutting a few lines of code):
ui.R:
library(shiny)
shinyUI(fluidPage(
title = 'MathJax Examples with in-line equations',
withMathJax(),
# section below allows in-line LaTeX via $ in mathjax. Replace less-than-sign with <
# and grater-than-sign with >
tags$div(HTML("less-than-sign script type='text/x-mathjax-config' greater-than-sign
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
less-than-sign /script greater-than-sign
")),
helpText('An irrational number $\\sqrt{2}$
and a fraction $1-\\frac{1}{2}$'),
helpText('and a fact about $\\pi$:$\\frac2\\pi = \\frac{\\sqrt2}2 \\cdot
\\frac{\\sqrt{2+\\sqrt2}}2 \\cdot
\\frac{\\sqrt{2+\\sqrt{2+\\sqrt2}}}2 \\cdots$'),
uiOutput('ex1')
))
server.R:
shinyServer(function(input, output, session) {
output$ex1 <- renderUI({
withMathJax(helpText('Dynamic output 1: $\\alpha^2$'))
})
})
I am running R version 3.5.2 on macOS, and shiny 1.2. The app output is some verbatim text instead of the expected blend of text and inline equations:
less-than-sign script type='text/x-mathjax-config' greater-than-sign MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['′,′
']]} }); less-than-sign /script greater-than-sign
and a fact about $\pi$:$\frac2\pi = \frac{\sqrt2}2 \cdot \frac{\sqrt{2+\sqrt2}}2 \cdot \frac{\sqrt{2+\sqrt{2+\sqrt2}}}2 \cdots$
Dynamic output 1: $\alpha^2$
Can it be because of my R environment?
less-than-sign
" and "greater-than-sign
"? Those should be replace with "<
" and ">
" as stated in the comment. Showing it like that was probably just a way to get around some escaping behaviour when posting it to the blog or something. – Becki