title: R shiny: rendering LaTeX interactively
body: <p>Using LaTeX in R shiny I found this tip <a href="https://stackoverflow.com/questions/22251956/r-shiny-how-to-output-a-good-looking-matrix-using-rendertable">How to output good-looking matrix</a> helpful. (Sorry my knowledge and reputation is too short to comment there.)
  But at least for me it doesn't work interactively. I found a solution to get the nice apperance. But I get raw LaTeX-code as if I run Stefanies example directly. 
  Here is my code</p>
  
  <pre><code>library(shiny)
  library(xtable)
  if (!exists("dummy.output")) dummy.output &lt;- NULL
  ui &lt;- 
    shinyUI(pageWithSidebar(
  
      # Application title
      headerPanel(
        HTML("App with $\\int \\alpha^2 $ und $$\\beta/3 $$")),
      # Sidebar with a slider input for number of observations
      sidebarPanel(
        tags$head( tags$script(src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full", type = 'text/javascript'),
                   tags$script(src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML', type = 'text/javascript'),
                   tags$script( "MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});", type='text/x-mathjax-config')
        ),
        sliderInput(
          inputId = "n",label = HTML("Dimension $ \\beta $"),
          value = 5,min = 3,max = 7,step = 1)
      ),
      # Show a plot of the generated distribution
      mainPanel(
        HTML("$\\alpha$ und $\\Omega$"),
        uiOutput("test.html"), 
        uiOutput("matrix.raw"), 
        #uiOutput("matrix.nicer"),#ging nicht
        p(br()),
        uiOutput("matrix.nicer"),
        p(br()),
        p("doesn' work, so brutal work with dummy.output made matrix ",
          "nice but then without intereactivity"),
        HTML(dummy.output),
        HTML("End.$\\clubsuit$")
      )
    ))
  
  server &lt;- function(input,output){
    output$test.html &lt;- renderPlot({plot(rnorm(50))})
    mk.matrix &lt;- reactive({
      n &lt;- input$n
      x &lt;- (5:(4+n^2))/4
      mm &lt;- matrix(x^2,nrow = n)
      rownames(mm) &lt;- letters[1:n]
      return(mm)
    })
    output$matrix.raw &lt;- renderTable({mk.matrix()})  
    output$matrix.nicer &lt;- renderUI({
      mm &lt;- mk.matrix()
      mm &lt;- print(
        xtable(mm, align=rep("c", ncol(mm)+1)), 
        floating=FALSE, tabular.environment="array", 
        comment=FALSE, print.results=FALSE)
      xx &lt;- paste0("$$", mm, "$$") 
      dummy.output &lt;&lt;- xx
      return(xx)
    })
  }
  
  runApp(list(ui=ui,server=server))
  </code></pre>
  
  <p>What cool works are all Symbols in Header and text. So I believe there is something wrong with my interactivity-settings. </p>