"code" option of the "include" directive, tests
[docutils.git] / test / functional / input / data / math.txt
blobc296fddec46a648037672e7f990cd11a98554316
1 Mathematics
2 -----------
4 Docutils supports inline math with the prefix or postfix ``:math:``
5 role specificator, :math:`n! + \sin(x_n^2)` and `A_\text{c} =
6 \frac{\pi}{4} d^2`:math:, as well as displayed math via the
7 `math` directive:
9 .. math::
11    f(\epsilon) = \frac{1}{1 + \exp\left(\frac{\varepsilon}{k_\text{B}T}\right)}
13 Content may start on the first line of the directive, e.g.
15 .. math:: N = \frac{\text{number of apples}}{7}
17 Equations can be labeled with a reference name using the ``:name:`` option.
18 See `eq:M`_ and `eq:schrödinger`_ below.
20 The determinant of the matrix
22 .. math:: :name: eq:M
24    \mathbf{M} = \left(\begin{matrix}a&b\\c&d\end{matrix}\right)
26 is :math:`|\mathbf{M}| = ad - bc`.
28 More than one display math block can be put in one math directive.
29 For example, the following sum and integral with limits:
31 .. math::
33           \int_0^1 x^n dx = \frac{1}{n + 1}
35           \sum_{n=1}^m n = \frac{m(m+1)}{2}
37 LaTeX-supported Unicode math symbols can be used in math roles and
38 directives:
40 The Schrödinger equation
42 .. math:: :name: eq:schrödinger
44    i\hbar \frac{∂}{∂t}Ψ = \hat{H}Ψ,
46 with the *wave function* :math:`Ψ`, describes how the quantum state of a
47 physical system changes in time.
49 Math-Accents:
50   .. list-table::
51      :class: borderless
53      * - :math:`\acute{a}`      ``\acute{a}``
54        - :math:`\dot{t}`        ``\dot{t}``
55        - :math:`\hat{\gamma}`   ``\hat{\gamma}``
57      * - :math:`\grave{a}`      ``\grave{a}``
58        - :math:`\ddot{t}`       ``\ddot{t}``
59        - :math:`\tilde{\alpha}` ``\tilde{\alpha}``
61      * - :math:`\breve{x}`      ``\breve{x}``
62        - :math:`\dddot{t}`      ``\dddot{t}``
63        - :math:`\vec{\imath}`   ``\vec{\imath}``
65      * - :math:`\check{a}`      ``\check{a}``
66        - :math:`\bar{a}`        ``\bar{a}``
67        - :math:`\vec{R}`        ``\vec{R}``
70        \widetilde{xxx}
71        \widehat{xxx}
73 Modulation Transfer Function:
75 .. math::
77  \text{MTF} = \left|\frac{\mathcal{F}\{s(x)\}}
78                          {\mathcal{F}\{ s(x)\} |_{ω_{x}=0}}\right|
79             = \mathrm{abs}\left(\frac
80                   {∫_{-∞}^{∞}s(x) \mathrm{e}^{\mathrm{i}ω_{x}x}\mathrm{d}{x}}
81                   {∫_{-∞}^{∞}s(x)\mathrm{d}{x}}
82               \right).
84 Math split over two lines: If a double backslash is detected outside a
85 ``\begin{...} \end{...}`` pair, the math code is wrapped in an AMSmath_
86 ``align`` environment:
88 .. math::
90    s_{\mathrm{out}}(x) & = s_{\mathrm{in}}(x') * s_δ(x-x') \\
91                        & = ∫ s_{\mathrm{in}}(x')s_δ(x-x')\mathrm{d}x'
93 Cases ("manually", with ``matrix`` environment):
95 .. math::
97    \mathrm{sgn}(x) = \left\{\begin{matrix}
98                        -1 & x<0\\
99                        1 & x>0
100                      \end{matrix}\right.
102 Cases with the AMSmath_ ``cases`` environment (not (yet) supported by
103 HTML writers with ``--math-output=MathML``):
105 .. math::
107    \mathrm{sgn}(x) = \begin{cases}
108                        -1 & x<0\\
109                         1 & x>0
110                      \end{cases}
112 .. _AMSmath: ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf