经过研究,我发现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页面。


当前回答

另一种解决方法是使用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} ”。“ 就变成: 阅读有关使用高级格式的更多信息。

TeXify不再工作。检查我的repo readme2tex-action如何创建Github动作。

添加动作。Yml文件到.github/workflow /action.yml。 如有必要,请更改分支主名称。

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

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

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

或者内联方程

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

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

我在标记文件的头部使用了以下内容

<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js? 
config=TeX-MML-AM_CHTML"
</script>

然后输入以下mathjax语句 $$x_{1,2} = \frac{-b \pm \sqrt{b^2-4ac}}{2b}.$$ 这对我很有效