LaTeX formula in a shiny panel

I want to display the -LaTeX formated-formula formula in the Shiny panel, but I cannot find a way to combine textOutput with withMathJax . I tried the following, but that did not work. Any help would be greatly appreciated.

- ui.r

 ... tabPanel("Diagnostics", h4(textOutput("diagTitle")), withMathJax(textOutput("formula")), ), ... 

- server.r

 ... output$formula <- renderText({ print(paste0("Use this formula: $$\\hat{A}_{\\small{\\textrm{M€}}} =", my_calculated_value,"$$")) }) ... 
+8
r shiny mathjax
source share
3 answers

ui.R

 tabPanel("Diagnostics", h4(textOutput("diagTitle")), withMathJax(uiOutput("formula")), ) 

server.R

 output$formula <- renderUI({ return(HTML(paste0("<p>,"Use this formula: $$\\hat{A}_{\\small{\\textrm{M€}}} =", my_calculated_value,"$$","</p>"))) }) 
+1
source share

How about using renderPrint() ?

Minimum working example:

 library(shiny) server <- function(input, output, session) { output$formula <- renderPrint({ print(paste0("Use this formula: $$\\hat{A}_{\\small{\\textrm{M€}}} =", 1,"$$")) }) } ui <- fluidPage( titlePanel("Hello Shiny!"), sidebarLayout( sidebarPanel( ), mainPanel( withMathJax(textOutput("formula")) ) ) ) shinyApp(ui = ui, server = server) 

EDIT: For me, it looks like this: enter image description here

0
source share

Use uiOutput on the user interface side and renderUI on the server side for dynamic content.

 ui <- fluidPage( withMathJax(), tabPanel( title = "Diagnostics", h4(textOutput("diagTitle")), uiOutput("formula") ) ) server <- function(input, output, session){ output$formula <- renderUI({ my_calculated_value <- 5 withMathJax(paste0("Use this formula: $$\\hat{A}_{\\small{\\textrm{M€}}} =", my_calculated_value,"$$")) }) } shinyApp(ui, server) 

Other examples: http://shiny.leg.ufpr.br/daniel/019-mathjax/

0
source share

All Articles