show_math | R Documentation |
Displays math equations in rstudioapi::viewer
or browser using the
MathJax javascript engine.
show_math(..., css = "", use_viewer = !is.null(getOption("viewer")))
... |
one or more character strings |
css |
optional css formatting |
use_viewer |
logical; if |
The html code (invisibly) as a character string.
show_html
, show_markdown
,
draw math symbols,
https://stackoverflow.com/q/31193843/2994949
## Not run:
form1 <- '$$A=\\frac{B}{C}$$'
form2 <- '$$
\\frac{1}{\\displaystyle 1+
\\frac{1}{\\displaystyle 2+
\\frac{1}{\\displaystyle 3+x}}} +
\\frac{1}{1+\\frac{1}{2+\\frac{1}{3+x}}}
$$'
form3 <- '\\frac{d}{dx}\\left( \\int_{0}^{x} f(u)\\,du\\right)=f(x)'
form4 <- "
\\forall a,b,c \\in \\mathbb{R} \\\\
\\begin{align}
a + b &= c \\\\
(a + b)(a - b) &= c(a - b) \\\\
a^2 - b^2 &= ca - cb \\\\
a^2 - ca &= b^2 - cb \\\\
a^2 - ca + \\frac{c^2}{4} &= b^2 - cb + \\frac{c^2}{4} \\\\
(a - \\frac{c}{2})^2 &= (b - \\frac{c}{2})^2 \\\\
a - \\frac{c}{2} &= b - \\frac{c}{2} \\\\
a &= b \\qquad \\qquad \\blacksquare \\\\
\\end{align}
"
show_math(form1)
cat(show_math(form4))
## use default browser
show_math(form2, use_viewer = FALSE)
## concatenate multiple expressions
show_math(form1, form2, form3, css = 'color: red; font-size: 15px;')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.