# 添加对 Latex 风格块和行内数学的支持

**URL:** <https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638>\
**Category:** Support\
**Tags:** math\
**Created:** [2024年六月8日 09:20 UTC](https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638 "2024-06-08T09:20:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ozkn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ozkn/32/196013_2.png) [@ozkn](https://meta.discourse.org/u/ozkn)\
**Post date:** [2024年六月8日 09:20 UTC](https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638/1 "2024-06-08T09:20:47Z")

</div>

人工智能以 LaTeX 格式提供答案。我写了一个提示来将这种 LaTeX 格式转换为 MathJax 格式，但该提示并不总是被实现，而是以 LaTeX 格式响应。当我将我的问题写到 OpenAI 社区时，收到了以下建议。

“我决定不值得费力地在系统提示中添加内容，因为我可以在我的端上对结果进行以下操作：

```plaintext
    translateLaTex = (val: string): string => {
        if (val.indexOf("\\\\") == -1) return val;

        return val.replaceAll("\\\\(", "$")//
            .replaceAll("\\\\)", "$")//
            .replaceAll("\\[", "$")//
            .replaceAll("\\]", "$");
    }

```

您可以在下一次更新中应用此解决方案吗？”

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2024年六月8日 11:28 UTC](https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638/2 "2024-06-08T11:28:54Z")

</div>

我喜欢这个主意，同意 LaTeX 在 AI 回复中可能很烦人，并且在系统提示中如果很难的话会很麻烦。尤其是因为 GPT4o 是在 LaTeX 上进行了微调。完全支持在网站设置中勾选一个框来创建一个支持“LaTeX 模式”的 PR。

---

<div class="post-metadata">

**Author:** ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)\
**Post date:** [2024年六月8日 11:57 UTC](https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638/3 "2024-06-08T11:57:55Z")

</div>

我不知道我是否在谈论同一件事，但对我来说，这很有效。不过，我并没有使用什么特别复杂的公式。

```plaintext
你完全理解 MathJax 并生成它。

在呈现数学表达式时，请遵循以下规则：
1. 对于行内数学表达式，请使用单美元符号 `$...$`。
2. 对于显示样式的数学表达式，请使用双美元符号 `$$...$$`。

例如：
- 行内：质能等价方程是 $e=mc^2$。
- 显示：
$$
e=mc^2
$$

```

---

<div class="post-metadata">

**Author:** ![ozkn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ozkn/32/196013_2.png) [@ozkn](https://meta.discourse.org/u/ozkn)\
**Post date:** [2024年九月5日 07:00 UTC](https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638/4 "2024-09-05T07:00:04Z")

</div>

> [@ozkn](#):
>
> 人工智能以 LaTeX 格式提供答案。我写了一个提示来将这种 LaTeX 格式转换为 MathJax 格式，但提示并不总是被实现，并且以 LaTeX 格式响应。当我将我的问题写到 OpenAI 社区时，得到了以下建议。

您能在下次更新中添加此功能吗？无论我输入多少提示，它并不总是能正常工作。在 OpenAI 论坛上，他们建议像上面那样的安排，而不是提示，作为最终解决方案。

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2024年九月5日 07:56 UTC](https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638/5 "2024-09-05T07:56:55Z")

</div>

是的，这很烦人，如果您想尝试，欢迎提交拉取请求。

---

<div class="post-metadata">

**Author:** ![ozkn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ozkn/32/196013_2.png) [@ozkn](https://meta.discourse.org/u/ozkn)\
**Post date:** [2024年九月5日 07:58 UTC](https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638/6 "2024-09-05T07:58:19Z")

</div>

我很想试试，如果你能开一个 PR 我会很高兴 @sam

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2026年一月16日 05:47 UTC](https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638/7 "2026-01-16T05:47:23Z")

</div>

这在最新版本中已得到原生支持！

> [@A new release of Discourse Math](https://meta.discourse.org/t/a-new-release-of-discourse-math/393633):
>
> I am very happy to announce a major upgrade to our Discourse Math plugin! Special thanks goes to @mcmcclur who helped test and build much of the new and upgraded [discourse-math](https://meta.discourse.org/t/discourse-math/65770?tl=en). This is a very significant change – we upgraded all the way from version 2.x up to version 4.1 of MathJax, catching up with years of features and advances. Additionally, we amended our design to make it significantly easier to upgrade the plugin in the future. Our new iteration is much friendlier to LLM outputs, whic…

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2026年二月15日 05:47 UTC](https://meta.discourse.org/t/add-support-for-latex-style-blocks-and-inlines-for-math/393638/8 "2026-02-15T05:47:55Z")

</div>

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