我正在制作一个闪亮的App。我使用withMathJax()
插入了一个方程式。我想左对齐方程并将字体更改为“Arial”。有人可以帮忙吗?
以下是示例问题:
library(shiny)
ui <- fluidPage(
titlePanel("hello"),
sidebarLayout(
sidebarPanel(),
mainPanel(
uiOutput("formula")
)
)
)
server <- function(input,output){
output$formula <- renderUI({
listcat <- c("Men","Ladies")
value <- 15
withMathJax(paste0("$$\\frac{",listcat[1], "\\cap ", listcat[2],"}{",listcat[1],"} =", value,"$$"))
})
}
您可以使用CSS来对齐公式:
div.MathJax_Display{
text-align: left !important;
}
注意:使用!important
确保不覆盖参数
然后用
tags$head(tags$style(HTML("...")))
插入闪亮的应用程序。
可重复的例子:
library(shiny)
ui <- fluidPage(
titlePanel("hello"),
tags$head(
tags$style(HTML("
div.MathJax_Display{
text-align: left !important;
}
"))
),
sidebarLayout(
sidebarPanel(),
mainPanel(
uiOutput("formula")
)
)
)
server <- function(input,output){
output$formula <- renderUI({
listcat <- c("Men","Ladies")
value <- 15
withMathJax(paste0("$$\\frac{",listcat[1], "\\cap ", listcat[2],"}{",listcat[1],"} =", value,"$$"))
})
}
shinyApp(ui, server)
请注意,MathJax不支持Arial,请参见:http://docs.mathjax.org/en/latest/font-support.html。