Is there a way to disable latex support with st.write and st.markdown (etc) ?
I’m not interested in latex but unfortunately the text I’m writing seems to include latex commands.
I remember seeing a code snippet on this forum using a html hack to disable latex so that text is written correctly but unfortunately I did not bookmark it and the search function does not return anything when it’s within code blocks.
Maybe there’s a way to escape all the “latex” characters so that they’re ignored by latex ?
Thanks for your question, could you perhaps share a code snippet of your app that is showing this. It may be helpful for the community in providing solutions.
I think the KaTeX typesetting is only triggered when it encounters a dollar sign in the string. Escaping those $ before calling st.write should get you covered.
My code outputs BASIC-like programming language code … you know like
Input A$
Print "Hello " + A$ + " How are you ?"
I think the $ sign is what triggers the latex renderer but I’m not sure if there are no other latex sequences that can be triggered (I’m not familiar with latex syntax)
Then I think your best option is using st.text() to show all the text.
Using st.write() or st.markdown() is going to be a pain, because you need to transform the original text into the markdown that will render exactly as the original text, and that can get very tricky. You can probably fix the latex issue by prepending a backslash to each “$”, but chances are you will find more things that do not render as you expect: bacticks, asterisks, dashes, brackets…
And of course you will get code that doesn’t work; basic interpreters won’t understand Print “Hello world”.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.