Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Markdown formula display in GitHub

When I write an R markdown file in RStudio and Knit HTML, my formulas (inline using $..$ or display using $$..$$) can be displayed properly. However, when I push my .md file to GitHub, these formulas cannot be displayed. They only show $..$ and $$..$$. Is there a way to let GitHub know how to parse latex formulas? Thanks!

like image 963
alittleboy Avatar asked Sep 19 '12 20:09

alittleboy


People also ask

How do you display formulas in Markdown?

Support for displaying math expressions has been a highly requested feature for over 8 years. From today, you can use the $ and $$ delimiters natively in Markdown on GitHub to insert math expressions in TeX and LaTeX style syntax. This content is then rendered using the highly popular MathJax library.

How do I insert a formula in Markdown?

To insert in-line math use the $ symbol within a Markdown cell. For example, the text $this_{is}^{inline}$ will produce: t h i s i s i n l i n e .

Can you use LaTeX in GitHub Markdown?

You can now use LaTeX style syntax to render math expressions within Markdown inline (using $ delimiters) or in blocks (using $$ delimiters).

How do I write an equation in LaTeX Markdown?

Mathematical formula We can use LaTeX to write mathematical equations in Markdown. To write inline LaTeX formula use a single $ before and after the equation and use a double $ to display equations.


2 Answers

Is there a way to let GitHub know how to parse latex formulas?

Some sites provide users with a service that would fit your need without any javascript involved: on-the-fly generation of images from url encoded latex formulas.

  • codecogs.com
  • iTex2Img.

given the following markdown syntax

![equation](https://latex.codecogs.com/gif.latex?1%2Bsin%28mc%5E2%29%0D%0A)

it will display the following image

equation

Note: In order for the image to be properly displayed, you'll have to ensure the querystring part of the url is percent encoded. You can easily find online tools to help you with that task, such as www.url-encode-decode.com

like image 126
nulltoken Avatar answered Sep 20 '22 22:09

nulltoken


I also looked for how to render math on GitHub pages, and after a long time of research I found a nice solution.

I used KateX to render formulas server side: it is really faster than MathJaX.

Please note that same solution could be arranged to work also client side, but, I prefer server side rendering, cause

  1. you know your server environment, but you don't know the client environment of your visitors
  2. it is also faster client side, if the formulas are rendered on the server, only once.

I wrote an article showing the steps, I hope it can help math divulgation: see Math on GitHub Pages.

like image 21
Gianluca Casati Avatar answered Sep 20 '22 22:09

Gianluca Casati