有没有办法在README中渲染LaTex ?md在GitHub存储库?我在谷歌上搜索了堆栈溢出,但没有一个相关的答案似乎可行。


当前回答

我刚刚发布了一个新版本的xhub,这是一个浏览器扩展,可以在GitHub页面中渲染LaTeX(和其他东西)。

缺点:

你必须安装扩展一次。

优点:

不需要设置任何东西。 用数学写下Markdown 显示数学: ' '的数学 E ^{i\pi} + 1 = 0 ' ' ' 直线数学$ ' a^2 + b^2 = c^2 ' (语法类似于GitLab。) 工作的明暗背景。(数学有文字颜色) 你可以像复制粘贴文本一样复制粘贴数学

作为一个例子,看看这个GitHub README:

其他回答

我测试了其他人提出的一些解决方案,我想推荐TeXify在agurodriguez的评论中创建和提出,并由Tom Hale进一步描述-我想发展他的答案,并给出一些理由,为什么这是一个非常好的解决方案:

TeXify is wrapper of Readme2Tex (mention in Lee answer). To use Readme2Tex you must install a lot of software in your local machine (python, latex, ...) - but TeXify is github plugin so you don't need to install anything in your local machine - you only need to online installation that plugin in you github account by pressing one button and choose repositories for which TeXify will have read/write access to parse your tex formulas and generate pictures. When in your repository you create or update *.tex.md file, the TeXify will detect changes and generate *.md file where latex formulas will be exchanged by its pictures saved in tex directory in your repo. So if you create README.tex.md file then TeXify will generate README.md with pictures instead tex formulas. So parsing tex formulas and generate documentation is done automagically on each commit&push :) Because all your formulas are changed into pictures in tex directory and README.md file use links to that pictures, you can even uninstall TeXify and all your old documentation will still works :). The tex directory and *.tex.md files will stay on repository so you have access to your original latex formulas and pictures (you can also safely store in tex directory your other documentation pictures "made by hand" - TeXify will not touch them). You can use equations latex syntax directly in README.tex.md file (without loosing .md markdown syntax) which is very handy. Julii in his answer proposed to use special links (with formulas) to external service e.g . http://latex.codecogs.com/gif.latex?s%3D%5Ctext%20%7B%20sensor%20reading%20%7D which is good however has some drawbacks: the formulas in links are not easy (handy) to read and update, and if there will be some problem with that third-party service your old documentation will stop work... In TeXify your old documentation will works always even if you uninstall that plugin (because all your pictures generated from latex formulas are stay in repo in tex directory). The Yuchao Jiang in his answer, proposed to use Jupyter Notebook which is also nice however have som drawbacks: you cannot use formulas directly in README.md file, you need to make link there to other file *.ipynb in your repo which contains latex (MathJax) formulas. The file *.ipynb format is JSON which is not handy to maintain (e.g. Gist don't show detailed error with line number in *.ipynb file when you forgot to put comma in proper place...).

这里是我的一些回购的链接,我使用TeXify的文档是从README.tex.md文件生成的。

更新

今天2020.12.13我意识到TeXify插件停止工作-即使重新安装后:(

您还可以看看我的工具latexMarkdown2Markdown,它可以将LaTeX转换为SVG并生成带有章节编号的内容表。

我的诀窍是用木星笔记本。

GitHub内置了呈现.ipynb文件的支持。你可以编写内联的LaTeX代码并在笔记本中显示,GitHub会为你呈现它。

下面是一个示例笔记本文件:https://gist.github.com/cyhsutw/d5983d166fb70ff651f027b2aa56ee4e

如果你对https://www.codecogs.com/latex/eqneditor.php有问题,我发现https://alexanderrodin.com/github-latex-markdown/对我有用。它生成您需要的Markdown代码,因此您只需将其剪切并粘贴到README中。md文档。

我刚刚发布了一个新版本的xhub,这是一个浏览器扩展,可以在GitHub页面中渲染LaTeX(和其他东西)。

缺点:

你必须安装扩展一次。

优点:

不需要设置任何东西。 用数学写下Markdown 显示数学: ' '的数学 E ^{i\pi} + 1 = 0 ' ' ' 直线数学$ ' a^2 + b^2 = c^2 ' (语法类似于GitLab。) 工作的明暗背景。(数学有文字颜色) 你可以像复制粘贴文本一样复制粘贴数学

作为一个例子,看看这个GitHub README: