# How to use subscript in Shiny ui with clean looks

Dear all, this is a rather simple question but I have not found an optimal solution for what I need. I am trying to include a subscript in the title of a Shiny App. Unfortunately neither of the solutions that I have found is good aesthetically.

library(shiny)
ui <- fluidPage(
withMathJax(),
h1(expression(Hello~O_2)),
h1("Hello $$O_2$$"),
h1("Hello O",tags$sub("2")) ) server <- function(input, output, session) { } shinyApp(ui, server)  The third option is the best, but the subscript is separated by one space. Do you know how to write subscript with clean look as in a ggplot?? Any help is appreciated, Oriol Hi Oriol, This reminded me of a question I once had. So, how about this? h1(HTML(paste0("Hello O",tags$sub("2"))))

1 Like

Thank you, that works! It is more or less what you asked 3 years ago, but in my search for solutions I did not find your question.

Greetings,

Oriol

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.