Mathematical expressions rendering is available in GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files. https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions
Examples: When $a \ne 0$, there are two solutions to $(ax^2 + bx + c = 0)$ and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}$$
The Cauchy-Schwarz Inequality $$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
Okay, Louis, but now I have something more elaborate, like this:
$$ H = \sqrt{\chi\,G\,\rho_0} \quad \mbox{with} \quad \chi = 8\pi \times \begin{cases} 1/8 & (: \mbox{OI}) \\ 1/6 & (: \mbox{Mach}) \\ 1/3 & (: \Lambda\mbox{CDM}) \\ 0.3883945571 & (: \mbox{UAC}) \end{cases} $$That doesn’t work well, isn’t it? Why not? It’s perfect MathJax!
That’s my problem: sometimes it works, sometimes it doesn’t.
Han
$$ H = \sqrt{\chi,G,\rho_0} \quad \mbox{with} \quad \chi = 8\pi \times \begin{cases} 1/8 & (: \mbox{OI}) \ 1/6 & (: \mbox{Mach}) \ 1/3 & (: \Lambda\mbox{CDM}) \ 0.3883945571 & (: \mbox{UAC}) \end{cases} $$
It works!
It seems that the opening
$$must be preceded by a blank line, and the closing one followed by a blank line, as in:You don’t need the rest of the
htmlmarkup.Thanks, but the ‘case’ statement doesn’t work properly: \ means new line in MathJax. Hmm, the preview shows a single backslash .. Does Markdown interfere with the math?
I see… It seems that a newline is required after the
\\here, bummer. And it does not handle accidental line spacing, as in\\[0.5em]😞.$$ \begin{cases} 1/8 & (: \mbox{OI}) \ 1/6 & (: \mbox{Mach}) \ 1/3 & (: \Lambda\mbox{CDM}) \ 0.3883945571 & (: \mbox{UAC}) \end{cases} $$
LaTeX is a later addition to the Markdown parser, it’s a bit finicky to use because they didn’t want a $4.98 amount trigger an error message as an invalid LaTeX equation.
The parser looks for
spacesimmediately outside of both $$ delimiters, and no space just after the $$ opening delimiter. It seems acommais also accepted after the closing delimiter $$.So,
If the equation is multiline, then a blank line is needed before and after the $$ delimiters (as @ftessier mentioned). The thin space
\,does not seem to be implemented.What you need to type is:
which is rendered as:
On the same line with spaces before and after the delimiters: $E = mc^2$, (a comma after the last delimiter is correctly rendered) and multiple lines with blank lines on both sides of the $$ delimiters:
$$H = \sqrt{\chi G \rho_0} \quad \mbox{with} \quad \chi = 8\pi \times \begin{cases} 1/8 & (: \mbox{OI}) \ 1/6 & (: \mbox{Mach}) \ 1/3 & (: \Lambda\mbox{CDM}) \ 0.3883945571 & (: \mbox{UAC}) \end{cases}$$