问题
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