Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

\u003c/code\u003e and end it with \u003ccode\u003e`$\u003c/code\u003e. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see \u003ca href=\"/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax\"\u003eBasic writing and formatting syntax\u003c/a\u003e.\u003c/p\u003e\n\u003cpre\u003e\u003ccode class=\"hljs language-text\"\u003eThis sentence uses `Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

delimiters to show math inline: $\\sqrt{3x-1}+(1+x)^2$\n\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003e\u003cpicture\u003e\u003csource srcset=\"/assets/cb-6685/mw-1440/images/help/writing/inline-math-markdown-rendering.webp 2x\" type=\"image/webp\"\u003e\u003cimg src=\"/assets/cb-6685/images/help/writing/inline-math-markdown-rendering.png\" alt=\"Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.\"\u003e\u003c/picture\u003e\u003c/p\u003e\n\u003cpre\u003e\u003ccode class=\"hljs language-text\"\u003eThis sentence uses $\\` and \\`$ delimiters to show math inline: Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

\\sqrt{3x-1}+(1+x)^2`$\n\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003e\u003cpicture\u003e\u003csource srcset=\"/assets/cb-10142/mw-1440/images/help/writing/inline-backtick-math-markdown-rendering.webp 2x\" type=\"image/webp\"\u003e\u003cimg src=\"/assets/cb-10142/images/help/writing/inline-backtick-math-markdown-rendering.png\" alt=\"Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.\"\u003e\u003c/picture\u003e\u003c/p\u003e\n\u003ch2 id=\"writing-expressions-as-blocks\" tabindex=\"-1\"\u003e\u003ca class=\"heading-link\" href=\"#writing-expressions-as-blocks\"\u003eWriting expressions as blocks\u003cspan class=\"heading-link-symbol\" aria-hidden=\"true\"\u003e\u003c/span\u003e\u003c/a\u003e\u003c/h2\u003e\n\u003cp\u003eTo add a math expression as a block, start a new line and delimit the expression with two dollar symbols \u003ccode\u003e$\u003c/code\u003e.\u003c/p\u003e\n\u003cdiv class=\"ghd-alert ghd-alert-success\" data-container=\"alert\"\u003e\u003cp class=\"ghd-alert-title\"\u003e\u003csvg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon mr-2\" aria-hidden\u003e\u003cpath d=\"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z\"\u003e\u003c/path\u003e\u003c/svg\u003eTip\u003c/p\u003e\n\u003cp\u003e If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see \u003ca href=\"/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#line-breaks\"\u003eBasic writing and formatting syntax\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cpre\u003e\u003ccode class=\"hljs language-text\"\u003e**The Cauchy-Schwarz Inequality**\\\n$\\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)$\n\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003e\u003cpicture\u003e\u003csource srcset=\"/assets/cb-6672/mw-1440/images/help/writing/math-expression-as-a-block-rendering.webp 1x\" type=\"image/webp\"\u003e\u003cimg src=\"/assets/cb-6672/images/help/writing/math-expression-as-a-block-rendering.png\" alt=\"Screenshot of rendered Markdown showing a complex equation. Bold text reads \u0026#x22;The Cauchy-Schwarz Inequality\u0026#x22; above the formula for the inequality.\"\u003e\u003c/picture\u003e\u003c/p\u003e\n\u003cp\u003eAlternatively, you can use the \u003ccode\u003e```math\u003c/code\u003e code block syntax to display a math expression as a block. With this syntax, you don't need to use \u003ccode\u003e$\u003c/code\u003e delimiters. The following will render the same as above:\u003c/p\u003e\n\u003cpre\u003e\u003ccode class=\"hljs language-text\"\u003e**The Cauchy-Schwarz Inequality**\n\n```math\n\\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)\n```\n\u003c/code\u003e\u003c/pre\u003e\n\u003ch2 id=\"writing-dollar-signs-in-line-with-and-within-mathematical-expressions\" tabindex=\"-1\"\u003e\u003ca class=\"heading-link\" href=\"#writing-dollar-signs-in-line-with-and-within-mathematical-expressions\"\u003eWriting dollar signs in line with and within mathematical expressions\u003cspan class=\"heading-link-symbol\" aria-hidden=\"true\"\u003e\u003c/span\u003e\u003c/a\u003e\u003c/h2\u003e\n\u003cp\u003eTo display a dollar sign as a character in the same line as a mathematical expression, you need to escape the non-delimiter \u003ccode\u003e$\u003c/code\u003e to ensure the line renders correctly.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eWithin a math expression, add a \u003ccode\u003e\\\u003c/code\u003e symbol before the explicit \u003ccode\u003e$\u003c/code\u003e.\u003c/p\u003e\n\u003cpre\u003e\u003ccode class=\"hljs language-text\"\u003eThis expression uses `\\Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

to display a dollar sign: Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

\\sqrt{\\$4}`$\n\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003e\u003cpicture\u003e\u003csource srcset=\"/assets/cb-30316/mw-1440/images/help/writing/dollar-sign-within-math-expression.webp 2x\" type=\"image/webp\"\u003e\u003cimg src=\"/assets/cb-30316/images/help/writing/dollar-sign-within-math-expression.png\" alt=\"Screenshot of rendered Markdown showing how a backslash before a dollar sign displays the sign as part of a mathematical expression.\"\u003e\u003c/picture\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eOutside a math expression, but on the same line, use span tags around the explicit \u003ccode\u003e$\u003c/code\u003e.\u003c/p\u003e\n\u003cpre\u003e\u003ccode class=\"hljs language-text\"\u003eTo split \u0026#x3C;span\u003e$\u0026#x3C;/span\u003e100 in half, we calculate $100/2$\n\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003e\u003cpicture\u003e\u003csource srcset=\"/assets/cb-22382/mw-1440/images/help/writing/dollar-sign-inline-math-expression.webp 2x\" type=\"image/webp\"\u003e\u003cimg src=\"/assets/cb-22382/images/help/writing/dollar-sign-inline-math-expression.png\" alt=\"Screenshot of rendered Markdown showing how span tags around a dollar sign display the sign as inline text not as part of a mathematical equation.\"\u003e\u003c/picture\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"further-reading\" tabindex=\"-1\"\u003e\u003ca class=\"heading-link\" href=\"#further-reading\"\u003eFurther reading\u003cspan class=\"heading-link-symbol\" aria-hidden=\"true\"\u003e\u003c/span\u003e\u003c/a\u003e\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"http://mathjax.org\"\u003eThe MathJax website\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github\"\u003eGetting started with writing and formatting on GitHub\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.github.com/gfm/\"\u003eGitHub Flavored Markdown Spec\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e","renderedPageHast":{"type":"root","children":[{"type":"element","tagName":"h2","properties":{"id":"about-writing-mathematical-expressions","tabIndex":-1},"children":[{"type":"element","tagName":"a","properties":{"className":["heading-link"],"href":"#about-writing-mathematical-expressions"},"children":[{"type":"text","value":"About writing mathematical expressions"},{"type":"element","tagName":"span","properties":{"className":["heading-link-symbol"],"ariaHidden":"true"},"children":[]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see "},{"type":"element","tagName":"a","properties":{"href":"http://en.wikibooks.org/wiki/LaTeX/Mathematics"},"children":[{"type":"text","value":"LaTeX/Mathematics"}]},{"type":"text","value":" in Wikibooks."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"GitHub'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 "},{"type":"element","tagName":"a","properties":{"href":"http://docs.mathjax.org/en/latest/input/tex/index.html#tex-and-latex-support"},"children":[{"type":"text","value":"the MathJax documentation"}]},{"type":"text","value":" and "},{"type":"element","tagName":"a","properties":{"href":"https://mathjax.github.io/MathJax-a11y/docs/#reader-guide"},"children":[{"type":"text","value":"the MathJax Accessibility Extensions Documentation"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Mathematical expressions rendering is available in GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"writing-inline-expressions","tabIndex":-1},"children":[{"type":"element","tagName":"a","properties":{"className":["heading-link"],"href":"#writing-inline-expressions"},"children":[{"type":"text","value":"Writing inline expressions"},{"type":"element","tagName":"span","properties":{"className":["heading-link-symbol"],"ariaHidden":"true"},"children":[]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ("},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"$"}]},{"type":"text","value":"), or start the expression with "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

"}]},{"type":"text","value":" and end it with "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"`$"}]},{"type":"text","value":". The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see "},{"type":"element","tagName":"a","properties":{"href":"/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax"},"children":[{"type":"text","value":"Basic writing and formatting syntax"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["hljs","language-text"]},"children":[{"type":"text","value":"This sentence uses `Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

delimiters to show math inline: $\\sqrt{3x-1}+(1+x)^2$\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"picture","properties":{},"children":[{"type":"element","tagName":"source","properties":{"srcset":"/assets/cb-6685/mw-1440/images/help/writing/inline-math-markdown-rendering.webp 2x","type":"image/webp"},"children":[]},{"type":"element","tagName":"img","properties":{"src":"/assets/cb-6685/images/help/writing/inline-math-markdown-rendering.png","alt":"Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared."},"children":[]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["hljs","language-text"]},"children":[{"type":"text","value":"This sentence uses $\\` and \\`$ delimiters to show math inline: Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

\\sqrt{3x-1}+(1+x)^2`$\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"picture","properties":{},"children":[{"type":"element","tagName":"source","properties":{"srcset":"/assets/cb-10142/mw-1440/images/help/writing/inline-backtick-math-markdown-rendering.webp 2x","type":"image/webp"},"children":[]},{"type":"element","tagName":"img","properties":{"src":"/assets/cb-10142/images/help/writing/inline-backtick-math-markdown-rendering.png","alt":"Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared."},"children":[]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"writing-expressions-as-blocks","tabIndex":-1},"children":[{"type":"element","tagName":"a","properties":{"className":["heading-link"],"href":"#writing-expressions-as-blocks"},"children":[{"type":"text","value":"Writing expressions as blocks"},{"type":"element","tagName":"span","properties":{"className":["heading-link-symbol"],"ariaHidden":"true"},"children":[]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To add a math expression as a block, start a new line and delimit the expression with two dollar symbols "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"$"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":"ghd-alert ghd-alert-success","dataContainer":"alert"},"children":[{"type":"element","tagName":"p","properties":{"className":["ghd-alert-title"]},"children":[{"type":"element","tagName":"svg","properties":{"version":"1.1","width":16,"height":16,"viewBox":"0 0 16 16","className":["octicon","mr-2"],"ariaHidden":true},"children":[{"type":"element","tagName":"path","properties":{"d":"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"},"children":[]}]},{"type":"text","value":"Tip"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":" If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see "},{"type":"element","tagName":"a","properties":{"href":"/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#line-breaks"},"children":[{"type":"text","value":"Basic writing and formatting syntax"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["hljs","language-text"]},"children":[{"type":"text","value":"**The Cauchy-Schwarz Inequality**\\\n$\\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)$\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"picture","properties":{},"children":[{"type":"element","tagName":"source","properties":{"srcset":"/assets/cb-6672/mw-1440/images/help/writing/math-expression-as-a-block-rendering.webp 1x","type":"image/webp"},"children":[]},{"type":"element","tagName":"img","properties":{"src":"/assets/cb-6672/images/help/writing/math-expression-as-a-block-rendering.png","alt":"Screenshot of rendered Markdown showing a complex equation. Bold text reads \"The Cauchy-Schwarz Inequality\" above the formula for the inequality."},"children":[]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Alternatively, you can use the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"```math"}]},{"type":"text","value":" code block syntax to display a math expression as a block. With this syntax, you don't need to use "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"$"}]},{"type":"text","value":" delimiters. The following will render the same as above:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["hljs","language-text"]},"children":[{"type":"text","value":"**The Cauchy-Schwarz Inequality**\n\n```math\n\\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)\n```\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"writing-dollar-signs-in-line-with-and-within-mathematical-expressions","tabIndex":-1},"children":[{"type":"element","tagName":"a","properties":{"className":["heading-link"],"href":"#writing-dollar-signs-in-line-with-and-within-mathematical-expressions"},"children":[{"type":"text","value":"Writing dollar signs in line with and within mathematical expressions"},{"type":"element","tagName":"span","properties":{"className":["heading-link-symbol"],"ariaHidden":"true"},"children":[]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To display a dollar sign as a character in the same line as a mathematical expression, you need to escape the non-delimiter "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"$"}]},{"type":"text","value":" to ensure the line renders correctly."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Within a math expression, add a "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"\\"}]},{"type":"text","value":" symbol before the explicit "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"$"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["hljs","language-text"]},"children":[{"type":"text","value":"This expression uses `\\Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

to display a dollar sign: Writing mathematical expressions - GitHub Docs
Skip to main content
Skip to content

Writing mathematical expressions

Use Markdown to display mathematical expressions on GitHub.

Who can use this feature?

Markdown can be used in the GitHub web interface.

About writing mathematical expressions

To enable clear communication of mathematical expressions, GitHub supports LaTeX formatted math within Markdown. For more information, see LaTeX/Mathematics in Wikibooks.

GitHub'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 GitHub Issues, GitHub Discussions, pull requests, wikis, and Markdown files.

Writing inline expressions

There are two options for delimiting a math expression inline with your text. You can either surround the expression with dollar symbols ($), or start the expression with $` and end it with `$. The latter syntax is useful when the expression you are writing contains characters that overlap with markdown syntax. For more information, see Basic writing and formatting syntax.

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

Screenshot of rendered Markdown showing an inline mathematical expression: the square root of 3x minus 1 plus (1 plus x) squared.

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

Screenshot of rendered Markdown showing an inline mathematical expression with backtick syntax: the square root of 3x minus 1 plus (1 plus x) squared.

Writing expressions as blocks

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

Tip

If you're writing in an .md file, you will need to use specific formatting to create a line break, such as ending the line with a backslash as shown in the example below. For more information on line breaks in Markdown, see Basic writing and formatting syntax.

**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 a complex equation. Bold text reads "The Cauchy-Schwarz Inequality" above the formula for the inequality.

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. The following will render the same as above:

**The Cauchy-Schwarz Inequality**

```math
\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)
```

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 not as part of a mathematical equation.

Further reading

\\sqrt{\\$4}`$\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"picture","properties":{},"children":[{"type":"element","tagName":"source","properties":{"srcset":"/assets/cb-30316/mw-1440/images/help/writing/dollar-sign-within-math-expression.webp 2x","type":"image/webp"},"children":[]},{"type":"element","tagName":"img","properties":{"src":"/assets/cb-30316/images/help/writing/dollar-sign-within-math-expression.png","alt":"Screenshot of rendered Markdown showing how a backslash before a dollar sign displays the sign as part of a mathematical expression."},"children":[]}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Outside a math expression, but on the same line, use span tags around the explicit "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"$"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["hljs","language-text"]},"children":[{"type":"text","value":"To split \u003cspan\u003e$\u003c/span\u003e100 in half, we calculate $100/2$\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"picture","properties":{},"children":[{"type":"element","tagName":"source","properties":{"srcset":"/assets/cb-22382/mw-1440/images/help/writing/dollar-sign-inline-math-expression.webp 2x","type":"image/webp"},"children":[]},{"type":"element","tagName":"img","properties":{"src":"/assets/cb-22382/images/help/writing/dollar-sign-inline-math-expression.png","alt":"Screenshot of rendered Markdown showing how span tags around a dollar sign display the sign as inline text not as part of a mathematical equation."},"children":[]}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"further-reading","tabIndex":-1},"children":[{"type":"element","tagName":"a","properties":{"className":["heading-link"],"href":"#further-reading"},"children":[{"type":"text","value":"Further reading"},{"type":"element","tagName":"span","properties":{"className":["heading-link-symbol"],"ariaHidden":"true"},"children":[]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"http://mathjax.org"},"children":[{"type":"text","value":"The MathJax website"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github"},"children":[{"type":"text","value":"Getting started with writing and formatting on GitHub"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://github.github.com/gfm/"},"children":[{"type":"text","value":"GitHub Flavored Markdown Spec"}]}]},{"type":"text","value":"\n"}]}],"data":{"quirksMode":false}},"miniTocItems":[{"contents":{"href":"#about-writing-mathematical-expressions","title":"About writing mathematical expressions"}},{"contents":{"href":"#writing-inline-expressions","title":"Writing inline expressions"}},{"contents":{"href":"#writing-expressions-as-blocks","title":"Writing expressions as blocks"}},{"contents":{"href":"#writing-dollar-signs-in-line-with-and-within-mathematical-expressions","title":"Writing dollar signs in line with and within mathematical expressions"}},{"contents":{"href":"#further-reading","title":"Further reading"}}],"permissions":"","includesPlatformSpecificContent":false,"includesToolSpecificContent":false,"defaultPlatform":"","defaultTool":"","product":"\u003cp\u003eMarkdown can be used in the GitHub web interface.\u003c/p\u003e","currentJourneyTrack":null,"detectedPlatforms":[],"detectedTools":[],"allTools":{"vscode":"Visual Studio Code","jetbrains":"JetBrains IDEs","visualstudio":"Visual Studio","cli":"GitHub CLI","webui":"Web browser","eclipse":"Eclipse","desktop":"Desktop","vimneovim":"Vim/Neovim","azure_data_studio":"Azure Data Studio","xcode":"Xcode","curl":"curl","javascript":"JavaScript","windowsterminal":"Windows Terminal","codespaces":"Codespaces","api":"API","mobile":"Mobile","copilotcli":"Copilot CLI","bash":"Bash","powershell":"PowerShell","skillsets":"Skillsets","agents":"Agents","jetbrains_beta":"JetBrains IDEs (Beta)","github_mobile":"GitHub Mobile","ides":"IDEs","importer_cli":"GitHub Enterprise Importer CLI"},"supportPortalVaIframeProps":{"supportPortalUrl":"https://support.github.com","vaFlowUrlParameter":""},"currentLayout":"default","currentPath":"/en/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions"}},"languagesContext":{"languages":{"en":{"name":"English","code":"en"},"es":{"name":"Spanish","code":"es","nativeName":"Español"},"ja":{"name":"Japanese","code":"ja","nativeName":"日本語"},"pt":{"name":"Portuguese","code":"pt","nativeName":"Português do Brasil"},"zh":{"name":"Simplified Chinese","code":"zh","hreflang":"zh-Hans","nativeName":"简体中文"},"ru":{"name":"Russian","code":"ru","nativeName":"Русский"},"fr":{"name":"French","code":"fr","nativeName":"Français"},"ko":{"name":"Korean","code":"ko","nativeName":"한국어"},"de":{"name":"German","code":"de","nativeName":"Deutsch"}}},"__N_SSP":true},"page":"/[versionId]/[productId]/[...restPage]","query":{"versionId":"free-pro-team@latest","productId":"get-started","restPage":["writing-on-github","working-with-advanced-formatting","writing-mathematical-expressions"]},"buildId":"AqffGoFt0KPxVQG-4wgxh","isFallback":false,"isExperimentalCompile":false,"gssp":true,"appGip":true,"locale":"en","locales":["en","es","ja","pt","zh","ru","fr","ko","de"],"defaultLocale":"en","scriptLoader":[]}