Fun workaround for displaying Latex in Streamlit!

Installing this Chrome plugin let’s you render Latex (using MathJax) on any website you choose. Then you can add things like this:

import streamlit as st

st.title('Latex is amazing')
$$x^2 = \frac{n^2+n}{10}$$

And get something that looks like:

Few caveats:

  1. When you change the formula it won’t refresh without a manual page refresh.
  2. I can’t vouch for this Chrome extension, so I highly recommend limiting the webpages this plugin has access to. You can do this by going to the “Details” page for the Chrome extension and restricting site access to or whatever the url is for where you are hosting Streamlit. If you are hosting it locally, then you must use rather than localhost. Chrome doesn’t allow you to restrict access to http://localhost:8501. By default, running Streamlit opens a browser tab to localhost so you’ll have to manually navigate to
  3. The rendered formulas will only display for people with this Chrome extension installed.

I think that support for Latex via MathJax really ought to be built into Streamlit. It’s super helpful!

1 Like

That’s an awesome workaround @veered. Welcome to the community :hugs: and I look forward to hearing many more cool ideas!

I’ve filed a feature request based on your awesome suggestion.

Please feel free to submit your own feature requests in the future! :slight_smile:


I started playing around with Streamlit last night and I’m super impressed. The live code reloading is extremely well done and seems like some crazy black magic. And having free-floating strings get written to Streamlit is a really nice touch. It materially improves the readability of the code.

I’ve started working on a project in Streamlit that might end up needing to do some weird things, so I’m sure I’ll have more ideas :slight_smile:

1 Like

Hey. It turns out that matplotlib can display LaTeX.

I used this fact to create a little gist that demonstrates rendering LaTeX formulae as images in Streamlit.

Enjoy! :slight_smile:

Update: As of v0.50.2, Streamlit supports Latex natively! :partying_face: