docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Math extensions

    (This page copied from https://github.com/xoofx/markdig/tree/master/src/Markdig.Tests/Specs. Used with permission.)

    Adds support for mathematics spans:

    Math Inline

    Allows to define a mathematic block embraced by $...$

    Example

    This is a \(math block\)

    This is a $math block$
    .
    <p>This is a <span class="math">\(math block\)</span></p>
    

    Example

    Or by $$...$$ embracing it by:

    This is a \(math block\)

    This is a $$math block$$
    .
    <p>This is a <span class="math">\(math block\)</span></p>
    

    Example

    Newlines inside an inline math are not allowed:

    This is not a $$math block$$ and? this is a \(math block\)

    This is not a $$math 
    block$$ and? this is a $$math block$$
    .
    <p>This is not a $$math
    block$$ and? this is a <span class="math">\(math block\)</span></p>
    

    Example

    This is not a $math block$ and? this is a \(math block\)

    This is not a $math 
    block$ and? this is a $math block$
    .
    <p>This is not a $math
    block$ and? this is a <span class="math">\(math block\)</span></p>
    

    Example

    An opening $ can be followed by a space if the closing is also preceded by a space $:

    This is a \(math block\)

    This is a $ math block $
    .
    <p>This is a <span class="math">\(math block\)</span></p>
    

    Example

    This is a \(math block\) after

    This is a $    math block     $ after
    .
    <p>This is a <span class="math">\(math block\)</span> after</p>
    

    Example

    This is a \(math block\) after

    This is a $$    math block     $$ after
    .
    <p>This is a <span class="math">\(math block\)</span> after</p>
    

    Example

    This is a not $ math block$ because there is not a whitespace before the closing

    This is a not $ math block$ because there is not a whitespace before the closing
    .
    <p>This is a not $ math block$ because there is not a whitespace before the closing</p>
    

    Example

    For the opening $ it requires a space or a punctuation before (but cannot be used within a word):

    This is not a m$ath block$

    This is not a m$ath block$
    .
    <p>This is not a m$ath block$</p>
    

    Example

    For the closing $ it requires a space after or a punctuation (but cannot be preceded by a space and cannot be used within a word):

    This is not a $math bloc$k

    This is not a $math bloc$k
    .
    <p>This is not a $math bloc$k</p>
    

    Example

    For the closing $ it requires a space after or a punctuation (but cannot be preceded by a space and cannot be used within a word):

    This is should not match a 16$ or a $15

    This is should not match a 16$ or a $15
    .
    <p>This is should not match a 16$ or a $15</p>
    

    Example

    A $ can be escaped between a math inline block by using the escape \\

    This is a \(math \$ block\)

    This is a $math \$ block$
    .
    <p>This is a <span class="math">\(math \$ block\)</span></p>
    

    Example

    At most, two $ will be matched for the opening and closing:

    This is a \($math block$\)

    This is a $$$math block$$$
    .
    <p>This is a <span class="math">\($math block$\)</span></p>
    

    Example

    Regular text can come both before and after the math inline

    This is a \(math block\) with text on both sides.

    This is a $math block$ with text on both sides.
    .
    <p>This is a <span class="math">\(math block\)</span> with text on both sides.</p>
    

    Example

    A mathematic block takes precedence over standard emphasis * _:

    This is *a \(math* block\)

    This is *a $math* block$
    .
    <p>This is *a <span class="math">\(math* block\)</span></p>
    

    Example

    An opening $$ at the beginning of a line should not be interpreted as a Math block:

    \(math\) starting at a line

    $$ math $$ starting at a line
    .
    <p><span class="math">\(math\)</span> starting at a line</p>
    

    Math Block

    The math block can spawn on multiple lines by having a $$ starting on a line. It is working as a fenced code block.

    \[ \begin{equation} \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15} \label{eq:sample} \end{equation} \]
    $$
    \begin{equation}
      \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
      \label{eq:sample}
    \end{equation}
    $$
    .
    <div class="math">
    \[
    \begin{equation}
      \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
      \label{eq:sample}
    \end{equation}
    \]</div>
    
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)