Using st.latex Within st.write

I am working on a site where I want to show a fair number of equations. I know I can use st.latex to render these equations. What I donā€™t know is how to ā€˜interleaveā€™ equations within text. In other words, I am wondering whether I can:

st.write("The pythagorean theorem is given by the equation {insert latex here}.")

There may not be a way to do that. I am thinking I have create a whole separate container just for equations. But if there is a way to interleave the latex into regular text, Iā€™d appreciate a tip as to how to do that.

You just need to surround the latex expression with dollar signs.

latex_expr = "a^2 + b^2 = c^2"
st.write(f"The pythagorean theorem is given by the equation ${latex_expr}$.")

image

Oooh. Thanks. Had not seen that!

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