question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow Latex and Markdown formatting in widget options

See original GitHub issue

Problem

It would be cool if users could format options for multiselect boxes and the like using LaTeX and/or Markdown. For example:

st.selectbox('', ['$k_A$', '$k_B$', '$k_D$', 'k<sub>C</sub>'])

Solution

MVP: What’s the smallest possible solution that would get 80% of the problem out of the way?

Possible additions: What are other things that could be added to the MVP over time to make it better?

Preferred solution: If you don’t like the MVP above, tell us why, and what you’d like done instead.

Additional context

HT Emmanual_Pean on the Streamlit forum: https://discuss.streamlit.io/t/html-or-latex-in-selectbox/2002

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
CFrezcommented, Jan 5, 2021

This would also be useful to have for labels inside of widgets. This is a screen shot of my use case, with the code, showing what should be if it was done in just text, vs it not rendering within the widget.

st.header('Given Properties')

col11, col12 = st.beta_columns(2)

with col11:
    '---'
    r'Backill Weight $\gamma$ pcf'
    '---'
    'Backfill Friction Angle $\phi$ degrees'

with col12:
    backfill = {}
    st.subheader('Backfill Soil Properties')
    backfill['weight'] = st.number_input(
        r'Backfill Weight $\gamma$ pcf', value=120, step=5)
    backfill['degree'] = st.number_input(
        'Backfill Friction Angle $\phi$ degrees', value=30)
st(latex)

Out of curiosity I just looked at the simple widgets: ✘ st.text('$\phi$')st.text(r'$\phi$')st.markdown('$\phi$')st.latex('\phi')st.write('$\phi$')st.title('$\phi$')st.header('$\phi$')st.subheader('$\phi$')

Looking into these, it seems like the difference is if it gets treated like text or markdown. Markdown goes through a process of getting rendered by Katex.

Screen Shot 2021-01-05 at 2 02 37 PM

Would it be possible to just have any string that goes through a widget get processed the same way as the markdown?

1reaction
rafisicscommented, Mar 23, 2021

I am also waiting for this feature to add LaTeX inside st.checkbox() and st.markdown().

Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing content with Markdown, LaTeX, and Shortcodes
Learn how to format content with Markdown, write math with LaTeX, add citations, and embed rich media such as image galleries, videos, ...
Read more >
Markdown Widget - Create Courses Using ... - Educative.io
The Markdown widget is super easy to use, let's have a look at it. ... To check out more formatting options available in...
Read more >
9.2 Display HTML widgets | R Markdown Cookbook
Then if you knit an Rmd document with HTML widgets to a non-HTML format, the HTML widgets will be displayed as static screenshots....
Read more >
Markdown syntax for files, widgets, and wikis - Azure DevOps
Markdown files or widgets ... In a Markdown file or widget, enter two spaces before the line break, and then select Enter to...
Read more >
Markdown and LaTeX introduction - Ashkan Mirzaee
Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found