1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/content/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions.md

3.9 KiB

title, intro, versions, shortTitle
title intro versions shortTitle
Writing mathematical expressions Use Markdown to display mathematical expressions on {% data variables.product.company_short %}.
feature
math
Mathematical expressions

About writing mathematical expressions

To enable clear communication of mathematical expressions, {% data variables.product.product_name %} supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

{% data variables.product.company_short %}'s math rendering capability uses MathJax; an open source, JavaScript-based display engine. MathJax supports a wide range of LaTeX macros, and several useful accessibility extensions. For more information, see the MathJax documentation and the MathJax Accessibility Extensions Documentation.

Mathematical expressions rendering is available in {% data variables.product.prodname_github_issues %}, {% data variables.product.prodname_discussions %}, pull requests, {% ifversion fpt or ghec or ghes > 3.6 or ghae > 3.6 %}wikis, {% endif %}and Markdown files.

Writing inline expressions

To include a math expression inline with your text, delimit the expression with a dollar symbol $.

This sentence uses `$` delimiters to show math inline:  $\sqrt{3x-1}+(1+x)^2$

Screenshot of rendered Markdown showing how a mathematical expression displays on {% data variables.product.prodname_dotcom %} with a square root symbol and an exponent.

Writing expressions as blocks

To add a math expression as a block, start a new line and delimit the expression with two dollar symbols $$.

**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)$$

Screenshot of rendered Markdown showing how a complex equation displays on {% data variables.product.prodname_dotcom %} with appropriate mathematical symbols, including parentheses and sigma notation.

{% ifversion math-fenced-blocks %}

Alternatively, you can use the ```math code block syntax to display a math expression as a block. With this syntax, you don't need to use $$ delimiters.

**Here is some math!**

```math
\sqrt{3}
```

Screenshot of rendered Markdown showing the bolded text "Here is some math!" followed by notation for the square root of 3.

{% endif %}

Writing dollar signs in line with and within mathematical expressions

To display a dollar sign as a character in the same line as a mathematical expression, you need to escape the non-delimiter $ to ensure the line renders correctly.

  • Within a math expression, add a \ symbol before the explicit $.
This expression uses `\$` to display a dollar sign: $\sqrt{\$4}$

Screenshot of rendered Markdown showing how a backslash before a dollar sign displays the sign as part of a mathematical expression.

  • Outside a math expression, but on the same line, use span tags around the explicit $.
To split <span>$</span>100 in half, we calculate $100/2$

Screenshot of rendered Markdown showing how span tags around a dollar sign display the sign as inline text rather than part of a mathematical equation.

Further reading