Latex Formatting
Most models mess up latex formatting when asked to give mathematical output. The LLM response shows up in raw latex instead of math.
Most models mess up latex formatting when asked to give mathematical output. The LLM response shows up in raw latex instead of math.
Log in to comment and vote
Comments18
Apricot Button
I found a workaround for most problems! If you go into the customization tab in settings and add:
“Do not use inline Latex with dollar signs (i.e. $x$) because Katex doesn't support it.” or even
“For inline Latex, prefer the \(x\) syntax over the single dollar sign $x$ syntax.”
That should fix the issue. I think the problem is that Katex only supports the backslash-parantheses form of inline Latex. (it doesn’t fix it all because Katex is still pretty limited)
Mark Florkowski
Working on adjusting the system prompt and making a few other changes, but this is a solid workaround for now.
Azure Chipmunk
This happens especially with inline math. Display math is properly rendered, but inline isn’t
Teal Astronaut
Amethyst Candy
Agree. In Gemini 2.5 pro, ChatGPT 4o often see latex errors
Scarlet Fuelcell
I agree with OP, this is very important for QOL.
Rose Beaver
I still have this issue, especially when using Gemini models. Take a look:
Lime Koala
I didnt even ask for a mathematical or latex output but o4-mini wanted to display its solution with it. I asked in german what a high profitable electrician takes (hourly wage)
Tan Tomato
Something changed and now inline latex rendering doesn’t work. Asked for the prompt and unless the models are all hallucinating the same it seems to be instructed to use
\\( … \\)instead of\( … \). If you ask the model explicitly to use the later it works well again.Mark Florkowski
Are you still experiencing this on new messages? I believe we pushed a fix for this yesterday afternoon.
Lavender Walrus
just got it today
Mark Florkowski
This looks unrelated, possibly invalid formatting
Purple Apple
Inconsistent formatting here, especially for matrices - not sure how to fix this?
Indigo Magnetosphere
This is still broken.
The issue in 95% of the cases I’ve seen seems to be that LaTeX rendering is fighting with list rendering.
Mark Florkowski
The screenshot you are showing is invalid syntax from the model. We cannot repair bad outputs from the models, but if they produce correct output, it will render perfectly fine.
Indigo Magnetosphere
The raw output looks perfectly fine
\[
\partial_t K =
-\frac{1}{2}(4\pi)^{-1/2} t^{-3/2} e^{-x^2/(4t)}
+ (4\pi t)^{-1/2} e^{-x^2/(4t)} \cdot \frac{x^2}{4t^2}.
\]
and KaTeX renders it correctly
Mark Florkowski
The hard brackets are escaped so they would not be properly detected, and also we do not use hard brackets in our renderer to notate a Latex block.
You copied the inner latex which is correct, but had you kept the escaped brakets, it fails on the katex site too
We cannot just strip off escaped hard brackets because that could affect other unrelated responses.
Indigo Magnetosphere
Escaped hard brackets are in fact supported; the problem is when the equation within contains lines starting with markdown syntax.
Markdown rendering should be disabled in LaTeX blocks, and if that breaks other responses (which I find unlikely), it is the other responses that are the wrong ones.
Given that GPT5 (presumably the most used model?) loves using this syntax, I think it’s strange to insist that this should be parsed incorrectly.
"be conservative in what you send, be liberal in what you accept"