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


当前回答

对于tex→图像转换,LaTeXiT工具可以产生更高质量的输出。我相信这是大多数TeX分布的标准,但如果你还没有它,你当然可以在网上找到它。你所需要做的就是把它放在TeX中,将图像拖到桌面,然后从桌面拖到图像托管站点(我使用imgur)。

其他回答

现在自2022年5月起,Github接受LATEX直接进入Markdown,唯一要做的就是把LATEX代码放在$$$$上

还有一件事,你可以使用markdown上的{\color{nameColor}text}为数学着色

$${\color{red}\sum\limits_{\color{lightblue}i=0}^{\color{orange}n} {\color{pink}i}} = \frac{\color{pink}n!}{\color{lightblue}k!(n-k)!}$$

图片中的例子:

$$\sum\limits_{i=0}^n i^2$$创建和:

但是github没有显示任何数学符号!请帮帮我,谢谢!

GitHub markdown解析由SunDown (ex libUpSkirt)库执行。

该库的座右铭是“符合标准、快速、安全的C语言markdown处理库”。考虑到你的问题,这里重要的词是“安全”:)。

事实上,允许执行javascript与MarkDown标准的文本到html合同有点不符。

此外,所有看起来像HTML标记的内容都被转义或删除。

告诉我如何显示数学符号在一般github markdown。

最好的办法是找一个类似yuml的网站。me,它可以通过解析提供的URL查询字符串生成实时图像。

更新

我发现一些网站为用户提供这样的服务:codedogs.com(似乎不再支持嵌入)或iTex2Img。 你可能想尝试一下。当然,其他的可能存在,一些Google-fu会帮助你找到它们。

给定以下markdown语法

![equation](http://www.sciweavers.org/tex2img.php?eq=1%2Bsin%28mc%5E2%29&bc=White&fc=Black&im=jpg&fs=12&ff=arev&edit=)

它将显示以下图像

注意:为了使图像正确显示,您必须确保url的querystring部分是百分比编码的。你可以很容易地找到在线工具来帮助你完成这项任务,比如www.url-encode-decode.com

我刚刚发布了一个小小的Chrome扩展,xhub,它可以让你在GitHub页面中使用LaTeX数学(以及更多)。

优点:

你不需要在你的回购中设置任何东西,只需在Markdown中使用数学(来自GitLab的sytax): 有些显示数学: ' '的数学 E ^{i\pi} + 1 = 0 ' ' ' 还有一些内联运算,$ ' a^2 + b^2 = c^2 ' $。 它同样适用于浅色和深色背景。 你可以复制粘贴数学

缺点:

你必须安装一次浏览器扩展。

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

自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} ”。“ 就变成: 阅读有关使用高级格式的更多信息。