我要打印TeX脚本$\simga$
,而不是$$\sigma$$
。但是,当我使用$\simga$
而不是$$\sigma$$
时,以下代码不起作用。
在以下代码中,请执行两次,第一次使用$\simga$
,第二次使用$$\sigma$$
。
library(shiny)
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a TeX
mainPanel(
shiny::uiOutput("formula")
)
)
)
# Define server
server <- function(input, output) {
output$formula <- renderUI({
# s<-"$\\sigma$" This is not functional, why???????
s<-"$$\\sigma$$"
withMathJax(s)
})
}
# Run the application
shinyApp(ui = ui, server = server)
编辑答案
确实可行,谢谢@Henryk Gerlach!
library(shiny)
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a TeX
mainPanel(
shiny::uiOutput("formula")
)
)
)
# Define server
server <- function(input, output) {
output$formula <- renderUI({
# s<-"$\\sigma$" This is not functional, why???????
s<-'\\( \\sigma \\) \\( \\sigma \\) \\( \\sigma \\)'
withMathJax(s)
})
}
# Run the application
shinyApp(ui = ui, server = server)
由于单币种不是以新行开头,因此正是单币种。谢谢@Henryk Gerlach,...很棒。