Skip to content

Displaying math equations in GitHub markdown

Jerry Morrison edited this page Apr 17, 2019 · 3 revisions

The best technique I found so far is a web service https://www.codecogs.com/latex/eqneditor.php where you can enter a LaTex equation on the webpage and get an image and an HTML snippet to embed into your Markdown page like this:

The snippet contains an <img src=...> tag to get the server to return an image, optionally wrapped in an <a href=...> tag so that clicking on the image will take you to their equation editor to edit the equation.

Note: The result is more reliably if you ask it for the "URL Encoded" output format and use that URL, even if you paste it into the img src tag of the "HTML (Edit)" output format or into the Markdown image link format ![alt_text](image_URL).

An example from docs/metabolism.md:

or without the hyperlink: an equation using URL encoding

mm_equation

More techniques discussed

  • on a GitHub Markup Issue
  • on Stack Overflow
  • Survey of Syntax for Math in MarkDown
  • There are web services to display GitHub documents in ipython and other formats, but those servers can't fetch the document from a private repo.
  • We could write a client-side git commit hook (GitHub doesn't support server-side git hooks) to convert math latex markup into images, but it looks like everyone needing it would have to install a latex-to-pdf renderer and then using imagemagick or something to convert that output to PNG format, or something similar.