Hi, the Math plugin seems to rely on the frontend for rendering. Therefore, our email users cannot receive the rendered math formula.
Is there any way to solve this problem?
Technically, yes… but it is tricky. We would need to load mathjax in mini racer (or node) simulate the DOM and render to an SVG.
I am sure it was done before by some people but can not find easy examples in the wild that are maintained. Probably worth testing if the node package even works for starters.
Absolutely open to it, if someone feels like helping out I would be delighted.
As I’d tracked down in that thread, because MathJax 3 handles its config file differently than MathJax 2.x does, upgrading this plugin will require more than just changing the URL.
artificial intelligence gives answers in latex format. I wrote a prompt to convert this latex format to mathjax format, but the prompt is not always implemented and responds in latex format. When I wrote my problem to the openai community, the following suggestion came.
"I decided it wasn’t even worth the effort of cluttering up a system prompt, when I could just do the following on my end with the results:
I like this idea, agree latex can be annoying in AI replies and system prompting out if it is hard. Double so cause GPT4o is fine tuned on latex. Totally support making some sort of PR with a switch to support “latex mode” if you check a box in site settings.
I don’t know if I’m talking about same thing, but for me this worked. I don’t use any really difficult formulas, though.
You fully understand MathJax and generate it.
When presenting mathematical expressions, use the following rules:
1. For inline mathematical expressions, use single dollar signs `$...$`.
2. For display-style mathematical expressions, use double dollar signs `$$...$$`.
For example:
- Inline: The equation of mass-energy equivalence is $e=mc^2$.
- Display:
$$
e=mc^2
$$
Can you add this feature in the next update. No matter how much I type prompt, it doesn’t always work properly. In the Openai forum, they suggest an arrangement like the one above, not prompt, as a definitive solution.
I’ve noticed that on Meta, math doesn’t get rendered in the preview window, but it does (I think) get rendered in posts. I’ll test that out here:
1 - a = 1 - \frac{1}{1 + e^{-z}}
In the preview window I’m seeing 1 - a = 1 - \frac{1}{1 + e^{-z}}.
Is that a known issue? I’m wondering if there’s a specific configuration that causes it.
On the DeepLearning.AI Discourse site, math gets rendered in the preview, but it’s really janky - it goes from mathjax code to rendered math on every keystroke. I’m not finding that issue on my local dev site. Again, I’m wondering if that’s a configuration issue.
There are new suggestions from the openai community regarding the problems I am experiencing. Are you planning to make an update about this? suggestions are as follows.
Suggestion 1;
def parse_stream_to_katex(stream: Stream):
"""
Takes an OpenAI Stream and replaces ChatGPT LaTeX delimiters
with KateX ones.
Yields text, not chunks
"""
last_text = ""
for chunk in stream:
text = chunk.choices[0].delta.content
if text:
# Sometimes delimiters like \( can be split over two chunks.
# If the previous chunk ended in \, prepend that to this chunk
if last_text.endswith("\\"):
text = last_text + text
text = (
text.replace(r"\[", "$$")
.replace(r"\]", "$$")
.replace(r"\(", "$")
.replace(r"\)", "$")
)
last_text = text
# If the text ends in \, we don't return it, we'll get include it in the next chunk
if not text.endswith("\\"):
yield text
Suggestion 2:
// MarkdownLaTeXRenderer.js
import React from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
import rehypeRaw from 'rehype-raw';
import rehypeKatex from 'rehype-katex';
const MarkdownLaTeXRenderer = ({ content }) => {
// Replace \[ with $$ and \] with $$ to ensure compatibility
const processedText = content
.replace(/\\\[/g, '$$$') // Replace all occurrences of \[ with $$
.replace(/\\\]/g, '$$$') // Replace all occurrences of \] with $$
.replace(/\\\(/g, '$$$') // Replace all occurrences of \( with $$
.replace(/\\\)/g, '$$$'); // Replace all occurrences of \) with $$
const remarkMathOptions = {
singleDollarTextMath: false,
};
return (
<ReactMarkdown
className="markdown-content"
children={processedText}
remarkPlugins={[[remarkMath, remarkMathOptions], remarkGfm]} // Pass options as the second element of the array
rehypePlugins={[rehypeRaw, rehypeKatex]} // Include rehypeRaw for HTML, rehypeKatex for LaTeX
/>
);
When I view mathematical formulas on my mobile device, I cannot see the entire formula correctly (the formula is too long). Does anyone know how to solve this issue?
Turning phone horizontally? But why it is quoted, and can that be the issue?
Otherwise. I asked from AI of my forum and it answered this (no idea if it is helpful or pure crap).
Solutions for Aligning Long Equations Using MathJaxAI
Jagster:
The forum utilizes MathJax for mathematics and equations. Occasionally, an equation is so long that it does not fit on a mobile screen. Is there a way to somehow break the equation into multiple lines?
Asiavastaaja:
MathJax does not directly support automatic line breaking for equations, but you can use some techniques to make long equations fit better on mobile screens. Here are a few tips:
Use the align environment: You can split the equation into multiple lines using the align environment. This allows you to align and distribute parts of the equation across several lines. For example:
$$
\begin{align}
a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u + v + w + x + y + z = 0
\end{align}
$$
Use the split environment: This is another way to break an equation into multiple lines. It is particularly useful when you want to split the equation into parts without needing alignment. For example:
$$
\begin{split}
a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u + v + w + x + y + z = 0
\end{split}
$$
Use the multline environment: This environment is designed for long equations that do not fit on a single line. It breaks the equation into multiple lines without alignment. For example:
$$
\begin{multline}
a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u + v + w + x + y + z = 0
\end{multline}
$$
These environments allow you to control the presentation of equations and ensure they are readable even on smaller screens. Remember that MathJax environments often require the amsmath package, which is usually enabled by default in MathJax.