Global setting of Latex font size (II) - Issue with version 1.50.0

Dear community, this topic was described and solved in October 2024 for older versions of streamlit. (Global setting of Latex font size). At that time I got kind assistance by edsaac and he proposed a workaround that did the job (see snippet below).
Short description: The problem was that Latex math fonts were too large (example code: “Wie groß ist die Gate-Source-Spannung in der gezeichneten Schaltung? $U_{\textrm{B}} = 44 V$; $R_1 = 10 k\Omega$; $R_2 = 1 k\Omega$; $R_3 = 2,2 k\Omega$ …” leads to the following output in markdown:

Now, in version 1.50.0 something has been changed and the workaround described in the link does not work any longer. Here, for completeness, the CSS inject that scaled the fonts in the desired manner in the past:

css = f"“”
span.math-inline {{
font-size: {0.8}rem;
}}
div.math-display {{
font-size: {0.8}rem;
}}
“”"
st.html(f"{css}")

Is there any workaround that fixes the issue for 1.50.0? Because of the many math symbols that are involved I would like to avoid formatting of each single math symbol. Thank you so much for your support in advance, best regards, Frank.

Try updating the CSS selectors:

/* Inline mode*/
span.katex span.katex-html {
    font-size: 0.8rem;
}

/* Display mode*/
span.katex-display span.katex span.katex-html{
    font-size: 0.8rem;
}

1 Like

You save my day, Edwin! Works again. If it allows your time, could you please briefly describe what’s going on behind the scenes. I would really like to understand how this works!
Best regards
Frank

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