经过研究,我发现mathjax可以做到这一点。但是当我在我的markdown文件中写一些例子时,它并没有显示正确的方程:

我在markdown文件的头部添加了这个:

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default"></script>

然后输入mathjax语句:

\(E=mc^2\),$$x_{1,2} = \frac{-b \pm \sqrt{b^2-4ac}}{2b}.$$

但是github没有显示任何数学符号!请帮帮我,谢谢! 告诉我如何显示数学符号在github markdown页面。


当前回答

Mathcha是一个复杂的数学编辑器,但它可以用于呈现单个方程并将其保存为纯html,然后可以将其作为内联html添加到文档中,也可以保存为SVG并作为图像插入。https://www.mathcha.io/

其他回答

另一种解决方法是使用jupyter笔记本,并在单元格中使用markdown模式来渲染方程。

基本的东西似乎很完美,比如居中方程

\begin{equation}
...
\end{equation}

或者内联方程

$ \sum_{\forall i}{x_i^{2}} $

虽然,我真正想要的一个函数在github中根本没有呈现是\mbox{},这是一个遗憾。但是,总的来说,这是在github上渲染方程的最成功的方式。

有一个很好的解决方案,你的问题-使用TeXify github插件(提到了汤姆黑尔的答案-但我开发了他的答案在下面给出的链接)-关于这个github插件的更多细节,并解释为什么这是一个很好的方法,你可以在答案中找到。

自2022年5月起正式支持:

Render mathematical expressions in Markdown You can now use LaTeX style syntax to render math expressions within Markdown inline (using $ delimiters) or in blocks (using $$ delimiters). Writing expressions as blocks To add math as a multiline block displayed separately from surrounding text, start a new line and delimit the expression with two dollar symbols $$. **The Cauchy-Schwarz Inequality** $$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$ Writing inline expressions To include a math expression inline with your text, delimit the expression with a dollar symbol $. This sentence uses `$` delimiters to show math inline: $\sqrt{3x-1}+(1+x)^2$ GitHub's math rendering capability uses MathJax; an open source, JavaScript-based display engine. MathJax supports a wide range of LaTeX macros and a number of useful accessibility extensions. For more information, see the MathJax documentation and the MathJax Accessibility Extensions documentation. Some users have previously used a workaround to generate images of mathematical expressions through API requests. Images generated this way will remain viewable, but this technique will no longer work. Going forward, expressions should be written directly in Markdown using LaTeX syntax as described above. For more information about authoring content with advanced formatting, see Working with advanced formatting in the GitHub documentation.


这仍然是测试版,并受到批评。 参见“GitHub上的数学:好,坏和丑”,来自Nico Schlömer。 语法介绍:

竞争Markdown和数学渲染器 难以解释的数学问题


正如brc-dd在评论中指出的:

2022年6月:

用于数学表达式的隔离块语法 除了已经支持的分隔符之外,用户现在还可以使用“math fenced”代码块语法来描述数学表达式。 如果使用此方法,则不需要两个美元符号$$分隔符。 这里有一些数学!** ' '的数学 \ sqrt {3} ”。“ 就变成: 阅读有关使用高级格式的更多信息。

如果只是想自己在浏览器中展示数学,你可以尝试Chrome扩展GitHub和MathJax。这很方便。

现在已经是2020年了,让我来总结一下源代码存储库主机的数学公式呈现支持的进展。

GitHub和Bitbucket

GitHub和Bitbucket仍然不支持数学公式的呈现,无论是默认的分隔符还是其他。

Bitbucket Cloud / BCLOUD-11192 -在MarkDown文档中添加LaTeX支持(BB-12552) GitHub / markup—呈现数学方程 GitHub / markup—支持latex GitHub社区论坛-[功能请求]乳胶数学在Markdown talk.commonmark.org—数学公式可以添加到markdown

GitHub近年来几乎没有取得任何实质性进展。

GitLab

GitLab已经得到了支持,但不是最常见的方式。它使用自己的分隔符。

This math is inline $`a^2+b^2=c^2`$.

This is on a separate line

```math
a^2+b^2=c^2
```

GitLab Flavored Markdown -- Math

谁支持通用分隔符?

Hugo使用的Markdown解析器

其他渲染方法

使用web api渲染根据一个黑客显示乳胶公式在GitHub markdown,你甚至可以写jupyter笔记本。 readme2tex