Wrap equations in box in Shiny Dashboard

纵然是瞬间 提交于 2020-01-05 04:40:05

问题


I'm having an issue in shinydashboard where equations that I'm writing are not wrapping when placed in a box. The equations are extending beyond the limits of the box. MWE:

library(shinydashboard)
library(shiny)

# UI
ui <- dashboardPage(
    dashboardHeader(),

    dashboardSidebar(),

    dashboardBody(
        fluidRow(
            column(width = 6,
                   box("Long Equation", width = 12,

                       h3(withMathJax("$$ \\alpha  + \\beta + \\gamma + \\delta + \\alpha  + \\beta + \\gamma + \\delta + \\alpha  + \\beta + \\gamma + \\delta + $$")))

                       )  
        )
    )
)

# Server
server <- function(input, output) {

}

# Run the application 
shinyApp(ui = ui, server = server)

This example yields:

I have had this same problem with dataframes in boxes as well, but can't find any answers online. Does anyone have a solution for ensuring that box contents don't extend beyond the boundary of the box?


回答1:


Here is the MathJax config to use:

  dashboardBody(
    tags$head(tags$script(type = "text/x-mathjax-config", 
                          'MathJax.Hub.Config({
  "HTML-CSS": { linebreaks: { automatic: true } },
         SVG: { linebreaks: { automatic: true } }
});')),
    fluidRow(......



来源:https://stackoverflow.com/questions/57609922/wrap-equations-in-box-in-shiny-dashboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!