37

Is it possible to include LaTeX-style math in any way with github repo wikis? Googling implies github no longer allows things like MathJax, but most references are years old. What (if any) alternatives are there to including LaTeX-formatted math in github wikis?

Aurelius
  • 1,146
  • 2
  • 13
  • 25
  • 3
    See http://stackoverflow.com/questions/11256433 – nulltoken Mar 06 '14 at 22:33
  • 8
    I was hoping there would be an update in the past two years. Using URL encoding is absurd for anything reasonably complex. – Aurelius Mar 07 '14 at 12:51
  • What about now? It's January 2017 ... and I'm still not sure what to use? – ComputerScientist Jan 25 '17 at 16:30
  • 2
    Possible duplicate of [How to show math equations in general github's markdown(not github's blog)](http://stackoverflow.com/questions/11256433/how-to-show-math-equations-in-general-githubs-markdownnot-githubs-blog) – Viliam Simko Feb 14 '17 at 09:15

6 Answers6

24

You can use chart.apis.google.com to render LaTeX formulas as PNG. It work nicely with Githhub's markdown:

Example (Markdown):

The ratio of the momentum to the velocity is
the relativistic mass, m.

![f1]

And the relativistic mass and the relativistic
kinetic energy are related by the formula:

![f2]

Einstein wanted to omit the unnatural second term
on the right-hand side, whose only purpose is
to make the energy at rest zero, and to declare
that the particle has a total energy, which obeys:
![f3] which is a sum of the rest energy ![f4]
and the kinetic energy.

[f1]: http://chart.apis.google.com/chart?cht=tx&chl=m=\frac{m_0}{\sqrt{1-{\frac{v^2}{c^2}}}}
[f2]: http://chart.apis.google.com/chart?cht=tx&chl=E_k=mc^2-m_0c^2
[f3]: http://chart.apis.google.com/chart?cht=tx&chl=E=mc^2
[f4]: http://chart.apis.google.com/chart?cht=tx&chl=m_0c^2

https

Some installations of Github Enterprise reject http and work only if you use https

Rendered: enter image description here

Aaron McDaid
  • 26,501
  • 9
  • 66
  • 88
Viliam Simko
  • 1,711
  • 17
  • 31
  • It looks like I need an extra \\ for the latex commands like \frac to render correctly using your method for example ```[f1]: http://chart.apis.google.com/chart?cht=tx&chl=m=\\frac{m_0}{\\sqrt{1-{\\frac{v^2}{c^2}}}}``` – muraly Mar 12 '17 at 15:06
  • I would say you just write single backslashes, it works in stackoverflow rendering and I tested it by copy-pasting to chrome addressbar. – Viliam Simko Mar 13 '17 at 16:39
  • It does the job, it looks decent when rendered, but the point of Markdown was to have something legible even when not rendered and having links make it illegible. It's not your fault, it's just limitation of GitHub :-( – dzieciou May 02 '22 at 20:23
12

For simple formulas (such as exponents etc) you may one just to use the available render languages. For example, using Textile, you can do:

_E = mc ^2^_

Thiw will be rendered as:

_ is used for italic style and ^ for superscript.

You can do the same thing in Markdown adding some HTML:

*E = mc<sup>2</sup>*

You can see it in action in this very place:

E = mc2

If you're looking for support for complex math formulas, then you have no better option than using a third-party service generating images for you. mathUrl looks interesting.

As input we give it E = mc ^ 2 and it generates the following link:

http://mathurl.com/render.cgi?E%20%3D%20mc%20%5E%202%5Cnocache

Community
  • 1
  • 1
Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474
2

There is good solution for your problem - use TeXify github plugin - more details about this plugin and explanation why this is good approach you can find in that answer.

Kamil Kiełczewski
  • 85,173
  • 29
  • 368
  • 345
1

GitLab Wiki and markdown supports formulas. I moved multiple repos for this reason.

rjmoggach
  • 1,458
  • 15
  • 27
1

Now GitHub officially supports showing Mathjax in the wiki!

In Markdown, just use $ as the deliminator of inline formulas, and $$ as the deliminator of display formulas.

Ulysses Zhan
  • 21
  • 1
  • 3
0

To add math equations to a GitHub wiki, I used mathURL as suggested by Ionică. It will render your LaTeX equations. Append .png to the generated url and use that url as an image (either block or inline) in your markdown.

Community
  • 1
  • 1
jeninco
  • 36
  • 4
  • While it is an option it is a pretty limited one. It doesn't support loading of LaTeX packages hence you have to stick to the very basics. – rbaleksandar Aug 30 '16 at 10:53