Display LaTeX equations in a shiny dashboard app in R -
i display rmd file latex equations in shiny dashboard app. i've run problems using includemarkdown()
, includehtml()
. here simplified app of i'm trying achieve. here app.r:
library(shinydashboard) ui <- dashboardpage( dashboardheader(title='my test application'), dashboardsidebar( sidebarmenu( menuitem("theory", tabname = "theory", icon = icon("book")) ) ), dashboardbody( tabitems( tabitem(tabname="theory", includemarkdown("theory.rmd") #includemarkdown("theory.md") #includehtml("theory.html") ) ) ) ) server <- function(input, output){ } shinyapp(ui = ui, server = server)
my theory.rmd file:
--- title: "theory" output: html_document: mathjax: "http://cdn.mathjax.org/mathjax/latest/mathjax.js?config=tex-ams-mml_htmlormml" --- here equation: $$q = a(h − c)^b$$
note in order run app, theory.rmd , app.r have saved in same directory (e.g. working directory) hand have have exact names. obtain markdown theory.md file of rmd file, do:
library(knitr) knit("theory.rmd","theory.md")
and obtain theory.html
file, press knit html button in theory.rmd file
when running app in browser or rstudio window, includemarkdown("theory.rmd")
or includemarkdown("theory.md")
, not render equations starts default in theory menu item, this: using includehtml("theory.html")
equations render correctly screen display shortened, , default not start in menu item, this:
but when clicked on theory correctly rendered equations:
is there way fix this? many thanks!
it possible wrap includemarkdown()
in withmathjax()
, won't need change .md
-file:
withmathjax(includemarkdown("theory.md"))
Comments
Post a Comment