Latex not getting rendered properly #156

Closed
opened 2025-11-11 14:08:39 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @jukofyork on GitHub (Jan 7, 2024).

Some Latex seems to get rendered but most doesn't seem to work, eg:

\begin{aligned} \text{Predict:} & x_{k} = f(x_{k-1}) + w_k \\ \text{Update:} & y_{k} = h(x_{k}) + v_k \ \end{aligned}

or any use of $...$ for expressions.

Originally created by @jukofyork on GitHub (Jan 7, 2024). Some Latex seems to get rendered but most doesn't seem to work, eg: ``` \begin{aligned} \text{Predict:} & x_{k} = f(x_{k-1}) + w_k \\ \text{Update:} & y_{k} = h(x_{k}) + v_k \ \end{aligned} ``` or any use of `$...$` for expressions.
Author
Owner

@tjbck commented on GitHub (Jan 7, 2024):

Hi, Thanks for creating this issue! The issue stems from LLMs not generating LaTeX in a correct format. You can also observe the same problem with ChatGPT like such:

image image

I'll try to see if there are any quick fixes to handle those edge cases, but I'll close this as not planned for now, Thanks!

@tjbck commented on GitHub (Jan 7, 2024): Hi, Thanks for creating this issue! The issue stems from LLMs not generating LaTeX in a correct format. You can also observe the same problem with ChatGPT like such: <img width="696" alt="image" src="https://github.com/ollama-webui/ollama-webui/assets/25473318/63bb2112-25ce-4c21-b265-f69e2dcd98dc"> <img width="432" alt="image" src="https://github.com/ollama-webui/ollama-webui/assets/25473318/2f44bd57-f5de-4196-a1bb-35bf13ae4404"> I'll try to see if there are any quick fixes to handle those edge cases, but I'll close this as not planned for now, Thanks!
Author
Owner

@tjbck commented on GitHub (Jan 7, 2024):

Just updated the UI rendering logic, I can't guarantee that the UI will render LaTeX 100% of the time as per the reason mentioned above, but it should cover more edge cases than before, Thanks!

@tjbck commented on GitHub (Jan 7, 2024): Just updated the UI rendering logic, I can't guarantee that the UI will render LaTeX 100% of the time as per the reason mentioned above, but it should cover more edge cases than before, Thanks!
Author
Owner

@YangSJ1 commented on GitHub (Jun 30, 2024):

Still it sometimes can't render latex properly, even when the expressions are in $$.

@YangSJ1 commented on GitHub (Jun 30, 2024): Still it sometimes can't render latex properly, even when the expressions are in $$.
Author
Owner

@jukofyork commented on GitHub (Jun 30, 2024):

I've figured out this so far:

If the model outputs like this:

$$
<expression>
$$

or this:

\[
<expression>
\]

It won't display correctly.

But it can display:

$$ <expression> $$

It also seems able to use \\( <expression \\) for inline expressions or:

\\[ <expression> \\]

BUT only if you double escape the \ symbols!

I haven't found a way yet to get it to display $ <expression> $ though, and sometimes it will try to indent the non-inline version and that seems to screw up too...

I found this out by asking GPT-4o to try lots of different versions, but sadly however much I tried; I couldn't find a system message that actually encourages models to use this format and they will nearly always just revert to the broken format until you remind them 😦

@jukofyork commented on GitHub (Jun 30, 2024): I've figured out this so far: If the model outputs like this: ``` $$ <expression> $$ ``` or this: ``` \[ <expression> \] ``` It won't display correctly. But it can display: ``` $$ <expression> $$ ``` It also seems able to use `\\( <expression \\)` for inline expressions or: ``` \\[ <expression> \\] ``` BUT only if you **double escape** the `\` symbols! I haven't found a way yet to get it to display `$ <expression> $` though, and sometimes it will try to indent the non-inline version and that seems to screw up too... I found this out by asking `GPT-4o` to try lots of different versions, but sadly however much I tried; I couldn't find a system message that actually encourages models to use this format and they will nearly always just revert to the broken format until you remind them 😦
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#156