35
votes

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?

5
I was hoping there would be an update in the past two years. Using URL encoding is absurd for anything reasonably complex.Aurelius
What about now? It's January 2017 ... and I'm still not sure what to use?ComputerScientist

5 Answers

23
votes

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

12
votes

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

2
votes

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.

1
votes

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

0
votes

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.