Description Usage Arguments Examples
render function for KaTeX in R
1 |
tex |
String containing the formula to be parsed and rendered |
tag |
String for the type of html tag to use. |
inline |
Logical to use |
style |
String with the style attributes, such as |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ## Not run:
# a simple mean formula
katex("\\frac{1}{n} \\sum_{i=i}^{n} x_{i}")
# to illustrate use with a different tag and some styling
katex(
"\\frac{1}{n} \\sum_{i=i}^{n} x_{i}"
,tag = "p"
,style = "color:blue; font-size:300%; text-align:center;"
)
# katex plays nicely with htmltools
library(htmltools)
html_print(tagList(
tags$div(
tags$pre( "\\frac{1}{n} \\sum_{i=i}^{n} x_{i}" )
, katex( "\\frac{1}{n} \\sum_{i=i}^{n} x_{i}", tag="span" )
)
))
# or if you want to customize your KaTeX experience
# use katex to just get the required dependencies
html_print(tagList(
tags$p( id = "katex-one" )
,tags$script( "
katex.render('\\\\frac{1}{n} \\\\sum_{i=i}^{n} x_{i}',document.getElementById('katex-one'))
")
,katex() # empty means just use for js/css dependencies
))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.