| 1 |
============================ |
| 2 |
LaTeX syntax for mathematics |
| 3 |
============================ |
| 4 |
|
| 5 |
.. role:: m(math) |
| 6 |
.. default-role:: math |
| 7 |
.. |latex| replace:: L\ :sup:`A`\ T\ :sub:`E`\ X |
| 8 |
|
| 9 |
:abstract: Docutils supports mathematical content with a `"math" |
| 10 |
directive`__ and `role`__. The input format is *LaTeX math |
| 11 |
syntax*\ [#math-syntax]_ with support for Unicode symbols. |
| 12 |
|
| 13 |
.. sectnum:: |
| 14 |
.. contents:: |
| 15 |
|
| 16 |
__ https://docutils.sourceforge.io/docs/ref/rst/directives.html#math |
| 17 |
__ https://docutils.sourceforge.io/docs/ref/rst/roles.html#math |
| 18 |
|
| 19 |
Inline formulas and displayed equations |
| 20 |
======================================= |
| 21 |
|
| 22 |
The **math role** can be used for inline mathematical expressions: |
| 23 |
``:math:`\psi(r) = \exp(-2r)``` will produce :m:`\psi(r)=\exp(-2r)`. |
| 24 |
Inside the backtics you can write anything you would write between dollar |
| 25 |
signs in a LaTeX document. [#math-syntax]_ |
| 26 |
|
| 27 |
.. tip:: |
| 28 |
|
| 29 |
If you put ``.. default-role:: math`` at the top of your |
| 30 |
document, you can write ```x^2``` instead of the longer |
| 31 |
version: ``:math:`x^2```. You can also introduce an |
| 32 |
abbreviation like this ``.. role:: m(math)``. That will allow |
| 33 |
you to write ``:m:`x^2``` or ```x^2`:m:``. |
| 34 |
|
| 35 |
|
| 36 |
The **math directive** is used for displayed equations. It corresponds to |
| 37 |
an ``equation*`` or ``align*`` environment in a LaTeX document. If you |
| 38 |
write:: |
| 39 |
|
| 40 |
.. math:: \psi(r) = e^{-2r} |
| 41 |
|
| 42 |
you will get: |
| 43 |
|
| 44 |
.. math:: \psi(r) = e^{-2r} |
| 45 |
|
| 46 |
A more complex example is the definition of the `Fourier transform`_:: |
| 47 |
|
| 48 |
.. math:: |
| 49 |
:name: Fourier transform |
| 50 |
|
| 51 |
(\mathcal{F}f)(y) |
| 52 |
= \frac{1}{\sqrt{2\pi}^{\ n}} |
| 53 |
\int_{\mathbb{R}^n} f(x)\, |
| 54 |
e^{-\mathrm{i} y \cdot x} \,\mathrm{d} x. |
| 55 |
|
| 56 |
which is rendered as: |
| 57 |
|
| 58 |
.. math:: |
| 59 |
:name: Fourier transform |
| 60 |
|
| 61 |
(\mathcal{F}f)(y) |
| 62 |
= \frac{1}{\sqrt{2\pi}^{\ n}} |
| 63 |
\int_{\mathbb{R}^n} f(x)\, |
| 64 |
e^{-\mathrm{i} y \cdot x} \,\mathrm{d} x. |
| 65 |
|
| 66 |
The ``:name:`` option puts a label on the equation that can be |
| 67 |
linked to by `hyperlink references`_. |
| 68 |
|
| 69 |
Displayed equations can use ``\\`` and ``&`` for line shifts and alignments:: |
| 70 |
|
| 71 |
.. math:: |
| 72 |
|
| 73 |
a &= (x + y)^2 & b &= (x - y)^2 \\ |
| 74 |
&= x^2 + 2xy + y^2 & &= x^2 - 2xy + y^2 |
| 75 |
|
| 76 |
LaTeX output will wrap it in an ``align*`` environment. |
| 77 |
The result is: |
| 78 |
|
| 79 |
.. math:: |
| 80 |
|
| 81 |
a &= (x + y)^2 & b &= (x - y)^2 \\ |
| 82 |
&= x^2 + 2xy + y^2 & &= x^2 - 2xy + y^2 |
| 83 |
|
| 84 |
|
| 85 |
.. [#math-syntax] The supported LaTeX commands include AMS extensions |
| 86 |
(see, e.g., the `Short Math Guide`_). Some of the shown symbols |
| 87 |
require the "amssymb" `LaTeX package`_ (or another package providing |
| 88 |
the AMS symbol macros) when exported with the "latex" writer. |
| 89 |
|
| 90 |
The support is limited to a subset of *LaTeX math* by the conversion |
| 91 |
required for many output formats. For HTML, the `math_output`_ |
| 92 |
configuration setting (or the corresponding ``--math-output`` command |
| 93 |
line option) selects between alternative output formats with different |
| 94 |
subsets of supported elements. If a writer does not support math |
| 95 |
typesetting, the content is inserted verbatim. |
| 96 |
|
| 97 |
.. _hyperlink references: |
| 98 |
../ref/rst/restructuredtext.html#hyperlink-references |
| 99 |
.. _Short Math Guide: |
| 100 |
https://mirrors.ctan.org/info/short-math-guide/short-math-guide.pdf |
| 101 |
.. _math_output: |
| 102 |
https://docutils.sourceforge.io/docs/user/config.html#math-output |
| 103 |
.. _LaTeX package: |
| 104 |
../../user/latex.html#latex-document-classes-and-packages |
| 105 |
|
| 106 |
|
| 107 |
Mathematical symbols |
| 108 |
==================== |
| 109 |
|
| 110 |
The following tables are adapted from the first edition of |
| 111 |
"The LaTeX Companion" (Goossens, Mittelbach, Samarin) and the |
| 112 |
AMS `Short Math Guide`_. |
| 113 |
|
| 114 |
|
| 115 |
Accents and embellishments |
| 116 |
-------------------------- |
| 117 |
|
| 118 |
The "narrow" accents are intended for a single-letter base. |
| 119 |
|
| 120 |
.. class:: colwidths-auto |
| 121 |
|
| 122 |
=========== ============= =========== ============= ============== ================ |
| 123 |
`\acute{x}` ``\acute{x}`` `\dot{t}` ``\dot{t}`` `\hat{x}` ``\hat{x}`` |
| 124 |
`\bar{v}` ``\bar{v}`` `\ddot{t}` ``\ddot{t}`` `\mathring{x}` ``\mathring{x}`` |
| 125 |
`\breve{x}` ``\breve{x}`` `\dddot{t}` ``\dddot{t}`` `\tilde{n}` ``\tilde{n}`` |
| 126 |
`\check{x}` ``\check{x}`` `\grave{x}` ``\grave{x}`` `\vec{x}` ``\vec{x}`` |
| 127 |
=========== ============= =========== ============= ============== ================ |
| 128 |
|
| 129 |
When adding an accent to an i or j in math, dotless variants can be |
| 130 |
obtained with ``\imath`` and ``\jmath``: `\hat \imath`, `\vec{\jmath}`. |
| 131 |
|
| 132 |
For embellishments that span multiple symbols, use: |
| 133 |
|
| 134 |
.. class:: colwidths-auto |
| 135 |
|
| 136 |
========================== ============================ =========================== ============================= |
| 137 |
`\widetilde{gbi}` ``\widetilde{gbi}`` `\widehat{gbi}` ``\widehat{gbi}`` |
| 138 |
`\overline{gbi}` ``\overline{gbi}`` `\underline{gbi}` ``\underline{gbi}`` |
| 139 |
`\overbrace{gbi}` ``\overbrace{gbi}`` `\underbrace{gbi}` ``\underbrace{gbi}`` |
| 140 |
`\overleftarrow{gbi}` ``\overleftarrow{gbi}`` `\underleftarrow{gbi}` ``\underleftarrow{gbi}`` |
| 141 |
`\overrightarrow{gbi}` ``\overrightarrow{gbi}`` `\underrightarrow{gbi}` ``\underrightarrow{gbi}`` |
| 142 |
`\overleftrightarrow{gbi}` ``\overleftrightarrow{gbi}`` `\underleftrightarrow{gbi}` ``\underleftrightarrow{gbi}`` |
| 143 |
========================== ============================ =========================== ============================= |
| 144 |
|
| 145 |
|
| 146 |
Binary operators |
| 147 |
---------------- |
| 148 |
.. class:: colwidths-auto |
| 149 |
|
| 150 |
================== ==================== ================= =================== ================== ==================== |
| 151 |
`*` ``*`` `\circledast` ``\circledast`` `\ominus` ``\ominus`` |
| 152 |
`+` ``+`` `\circledcirc` ``\circledcirc`` `\oplus` ``\oplus`` |
| 153 |
`-` ``-`` `\circleddash` ``\circleddash`` `\oslash` ``\oslash`` |
| 154 |
`:` ``:`` `\cup` ``\cup`` `\otimes` ``\otimes`` |
| 155 |
`\Cap` ``\Cap`` `\curlyvee` ``\curlyvee`` `\pm` ``\pm`` |
| 156 |
`\Cup` ``\Cup`` `\curlywedge` ``\curlywedge`` `\rightthreetimes` ``\rightthreetimes`` |
| 157 |
`\amalg` ``\amalg`` `\dagger` ``\dagger`` `\rtimes` ``\rtimes`` |
| 158 |
`\ast` ``\ast`` `\ddagger` ``\ddagger`` `\setminus` ``\setminus`` |
| 159 |
`\bigcirc` ``\bigcirc`` `\diamond` ``\diamond`` `\smallsetminus` ``\smallsetminus`` |
| 160 |
`\bigtriangledown` ``\bigtriangledown`` `\div` ``\div`` `\sqcap` ``\sqcap`` |
| 161 |
`\bigtriangleup` ``\bigtriangleup`` `\divideontimes` ``\divideontimes`` `\sqcup` ``\sqcup`` |
| 162 |
`\boxdot` ``\boxdot`` `\dotplus` ``\dotplus`` `\star` ``\star`` |
| 163 |
`\boxminus` ``\boxminus`` `\doublebarwedge` ``\doublebarwedge`` `\times` ``\times`` |
| 164 |
`\boxplus` ``\boxplus`` `\gtrdot` ``\gtrdot`` `\triangleleft` ``\triangleleft`` |
| 165 |
`\boxtimes` ``\boxtimes`` `\intercal` ``\intercal`` `\triangleright` ``\triangleright`` |
| 166 |
`\bullet` ``\bullet`` `\leftthreetimes` ``\leftthreetimes`` `\uplus` ``\uplus`` |
| 167 |
`\cap` ``\cap`` `\lessdot` ``\lessdot`` `\vee` ``\vee`` |
| 168 |
`\cdot` ``\cdot`` `\ltimes` ``\ltimes`` `\veebar` ``\veebar`` |
| 169 |
`\centerdot` ``\centerdot`` `\mp` ``\mp`` `\wedge` ``\wedge`` |
| 170 |
`\circ` ``\circ`` `\odot` ``\odot`` `\wr` ``\wr`` |
| 171 |
================== ==================== ================= =================== ================== ==================== |
| 172 |
|
| 173 |
|
| 174 |
Extensible delimiters |
| 175 |
--------------------- |
| 176 |
Unless you indicate otherwise, delimiters in math formulas remain at the |
| 177 |
standard size regardless of the height of the enclosed material. To get |
| 178 |
adaptable sizes, use ``\left`` and ``\right`` prefixes, for example |
| 179 |
`g(A,B,Y) = f \left(A,B,X=h^{[X]}(Y)\right)` or |
| 180 |
|
| 181 |
.. math:: a_n = \left(\frac{1}{2}\right)^n |
| 182 |
|
| 183 |
Use ``.`` for "empty" delimiters: |
| 184 |
|
| 185 |
.. math:: A = \left . \frac{1}{1-n}\, \right |_{n=0}^\infty |
| 186 |
|
| 187 |
See also the commands for fixed `delimiter sizes`_ below. |
| 188 |
|
| 189 |
The following symbols extend when used with ``\left`` and ``\right``: |
| 190 |
|
| 191 |
Pairing delimiters |
| 192 |
~~~~~~~~~~~~~~~~~~ |
| 193 |
.. class:: colwidths-auto |
| 194 |
|
| 195 |
=============== ================= ========================= =========================== |
| 196 |
`( )` ``( )`` `\langle \rangle` ``\langle \rangle`` |
| 197 |
`[ ]` ``[ ]`` `\lceil \rceil` ``\lceil \rceil`` |
| 198 |
`\{ \}` ``\{ \}`` `\lfloor \rfloor` ``\lfloor \rfloor`` |
| 199 |
`\lvert \rvert` ``\lvert \rvert`` `\lgroup \rgroup` ``\lgroup \rgroup`` |
| 200 |
`\lVert \rVert` ``\lVert \rVert`` `\lmoustache \rmoustache` ``\lmoustache \rmoustache`` |
| 201 |
=============== ================= ========================= =========================== |
| 202 |
|
| 203 |
|
| 204 |
Nonpairing delimiters |
| 205 |
~~~~~~~~~~~~~~~~~~~~~ |
| 206 |
.. class:: colwidths-auto |
| 207 |
|
| 208 |
==== ====== ============ ============== ============ ============== |
| 209 |
`|` ``|`` `\vert` ``\vert`` `\arrowvert` ``\arrowvert`` |
| 210 |
`\|` ``\|`` `\Vert` ``\Vert`` `\Arrowvert` ``\Arrowvert`` |
| 211 |
`/` ``/`` `\backslash` ``\backslash`` `\bracevert` ``\bracevert`` |
| 212 |
==== ====== ============ ============== ============ ============== |
| 213 |
|
| 214 |
The use of ``|`` and ``\|`` for pairs of vertical bars may produce |
| 215 |
incorrect spacing, e.g., ``|k|=|-k|`` produces `|k| = |−k|` and |
| 216 |
``|\sin(x)|`` produces `|\sin(x)|`. The pairing delimiters, e.g. |
| 217 |
`\lvert -k\rvert` and `\lvert\sin(x)\rvert`, prevent this problem |
| 218 |
(in LaTeX and MathJax). |
| 219 |
|
| 220 |
.. TODO: fix spacing before unary minus (see also cases example below). |
| 221 |
|
| 222 |
Extensible vertical arrows |
| 223 |
-------------------------- |
| 224 |
.. class:: colwidths-auto |
| 225 |
|
| 226 |
=============================== ====================================== |
| 227 |
`\uparrow` ``\uparrow`` `\Uparrow` ``\Uparrow`` |
| 228 |
`\downarrow` ``\downarrow`` `\Downarrow` ``\Downarrow`` |
| 229 |
`\updownarrow` ``\updownarrow`` `\Updownarrow` ``\Updownarrow`` |
| 230 |
=============================== ====================================== |
| 231 |
|
| 232 |
|
| 233 |
Functions (named operators) |
| 234 |
--------------------------- |
| 235 |
.. class:: colwidths-auto |
| 236 |
|
| 237 |
========= =========== ========= =========== ============= ================ |
| 238 |
`\arccos` ``\arccos`` `\gcd` ``\gcd`` `\Pr` ``\Pr`` |
| 239 |
`\arcsin` ``\arcsin`` `\hom` ``\hom`` `\projlim` ``\projlim`` |
| 240 |
`\arctan` ``\arctan`` `\inf` ``\inf`` `\sec` ``\sec`` |
| 241 |
`\arg` ``\arg`` `\injlim` ``\injlim`` `\sin` ``\sin`` |
| 242 |
`\cos` ``\cos`` `\ker` ``\ker`` `\sinh` ``\sinh`` |
| 243 |
`\cosh` ``\cosh`` `\lg` ``\lg`` `\sup` ``\sup`` |
| 244 |
`\cot` ``\cot`` `\lim` ``\lim`` `\tan` ``\tan`` |
| 245 |
`\coth` ``\coth`` `\liminf` ``\liminf`` `\tanh` ``\tanh`` |
| 246 |
`\csc` ``\csc`` `\limsup` ``\limsup`` `\varlimsup` ``\varlimsup`` |
| 247 |
`\deg` ``\deg`` `\ln` ``\ln`` `\varliminf` ``\varliminf`` |
| 248 |
`\det` ``\det`` `\log` ``\log`` `\varprojlim` ``\varprojlim`` |
| 249 |
`\dim` ``\dim`` `\max` ``\max`` `\varinjlim` ``\varinjlim`` |
| 250 |
`\exp` ``\exp`` `\min` ``\min`` |
| 251 |
========= =========== ========= =========== ============= ================ |
| 252 |
|
| 253 |
Named operators outside the above list can be typeset with |
| 254 |
``\operatorname{name}``, e.g. |
| 255 |
|
| 256 |
.. math:: \operatorname{sgn}(-3) = -1. |
| 257 |
|
| 258 |
.. TODO: \operatorname* for function name with limits. |
| 259 |
|
| 260 |
The ``\DeclareMathOperator`` command can only be used in the |
| 261 |
`LaTeX preamble`_. |
| 262 |
|
| 263 |
.. _LaTeX preamble: latex.html#latex-preamble |
| 264 |
|
| 265 |
|
| 266 |
Greek letters |
| 267 |
------------- |
| 268 |
|
| 269 |
Greek letters that have Latin look-alikes are rarely used in math |
| 270 |
formulas and not supported by LaTeX. |
| 271 |
|
| 272 |
.. class:: colwidths-auto |
| 273 |
|
| 274 |
========== ============ ========== ============ ========== ============ ============== =============== |
| 275 |
`\Gamma` ``\Gamma`` `\alpha` ``\alpha`` `\mu` ``\mu`` `\omega` ``\omega`` |
| 276 |
`\Delta` ``\Delta`` `\beta` ``\beta`` `\nu` ``\nu`` `\digamma` ``\digamma`` |
| 277 |
`\Lambda` ``\Lambda`` `\gamma` ``\gamma`` `\xi` ``\xi`` `\varepsilon` ``\varepsilon`` |
| 278 |
`\Phi` ``\Phi`` `\delta` ``\delta`` `\pi` ``\pi`` `\varkappa` ``\varkappa`` |
| 279 |
`\Pi` ``\Pi`` `\epsilon` ``\epsilon`` `\rho` ``\rho`` `\varphi` ``\varphi`` |
| 280 |
`\Psi` ``\Psi`` `\zeta` ``\zeta`` `\sigma` ``\sigma`` `\varpi` ``\varpi`` |
| 281 |
`\Sigma` ``\Sigma`` `\eta` ``\eta`` `\tau` ``\tau`` `\varrho` ``\varrho`` |
| 282 |
`\Theta` ``\Theta`` `\theta` ``\theta`` `\upsilon` ``\upsilon`` `\varsigma` ``\varsigma`` |
| 283 |
`\Upsilon` ``\Upsilon`` `\iota` ``\iota`` `\phi` ``\phi`` `\vartheta` ``\vartheta`` |
| 284 |
`\Xi` ``\Xi`` `\kappa` ``\kappa`` `\chi` ``\chi`` |
| 285 |
`\Omega` ``\Omega`` `\lambda` ``\lambda`` `\psi` ``\psi`` |
| 286 |
========== ============ ========== ============ ========== ============ ============== =============== |
| 287 |
|
| 288 |
In LaTeX, the default font for capital Greek letters is upright/roman. |
| 289 |
*Italic* capital Greek letters can be obtained by loading a `package |
| 290 |
providing the "ISO" math style`__. They are used by default in MathML. |
| 291 |
|
| 292 |
Individual Greek italic capitals can also be achieved preceding the |
| 293 |
letter name with ``var`` like ``\varPhi``: |
| 294 |
`\varGamma\ \varDelta\ \varLambda\ \varPhi\ \varPi\ \varPsi\ \varSigma\ |
| 295 |
\varTheta\ \varUpsilon\ \varXi\ \varOmega` |
| 296 |
|
| 297 |
|
| 298 |
__ https://mirrors.ctan.org/macros/latex/contrib/isomath/isomath.html#table-2 |
| 299 |
|
| 300 |
|
| 301 |
Letterlike symbols |
| 302 |
------------------ |
| 303 |
.. class:: colwidths-auto |
| 304 |
|
| 305 |
============= =============== ========== ============ ========== ============ =========== ============= |
| 306 |
`\forall` ``\forall`` `\aleph` ``\aleph`` `\hbar` ``\hbar`` `\ell` ``\ell`` |
| 307 |
`\complement` ``\complement`` `\beth` ``\beth`` `\hslash` ``\hslash`` `\wp` ``\wp`` |
| 308 |
`\exists` ``\exists`` `\gimel` ``\gimel`` `\Im` ``\Im`` `\Re` ``\Re`` |
| 309 |
`\Finv` ``\Finv`` `\daleth` ``\daleth`` `\imath` ``\imath`` `\circledR` ``\circledR`` |
| 310 |
`\Game` ``\Game`` `\partial` ``\partial`` `\jmath` ``\jmath`` `\circledS` ``\circledS`` |
| 311 |
`\mho` ``\mho`` `\eth` ``\eth`` `\Bbbk` ``\Bbbk`` |
| 312 |
============= =============== ========== ============ ========== ============ =========== ============= |
| 313 |
|
| 314 |
Mathematical Alphabets |
| 315 |
---------------------- |
| 316 |
|
| 317 |
Mathematical alphabets select a combination of font attributes (shape, |
| 318 |
weight, family) [#]_. They are intended for mathematical variables where |
| 319 |
style variations are important semantically. |
| 320 |
|
| 321 |
.. class:: colwidths-auto |
| 322 |
|
| 323 |
=============== ============================ ========================== |
| 324 |
command example result |
| 325 |
=============== ============================ ========================== |
| 326 |
``\mathbf`` ``\mathbf{r}^2=x^2+y^2+z^2`` `\mathbf{r}^2=x^2+y^2+z^2` |
| 327 |
``\mathbb`` ``\mathbb{R \subset C}`` `\mathbb{R \subset C}` |
| 328 |
``\mathcal`` ``\mathcal{F}f(x)`` `\mathcal{F}f(x)` |
| 329 |
``\mathfrak`` ``\mathfrak{a}`` `\mathfrak{a}` |
| 330 |
``\mathit`` ``\mathit{\Gamma}`` `\mathit{\Gamma}` |
| 331 |
``\mathrm`` ``s_\mathrm{out}`` `s_\mathrm{out}` |
| 332 |
``\mathsf`` ``\mathsf x`` `\mathsf x` |
| 333 |
``\mathtt`` ``\mathtt{0.12}`` `\mathtt{0.12}` |
| 334 |
=============== ============================ ========================== |
| 335 |
|
| 336 |
.. [#] TeX’s *math alphabets* correspond to the `mathematical |
| 337 |
alphanumeric symbols`__ block in Unicode and the "mathvariant" `style |
| 338 |
attribute`__ in MathML. |
| 339 |
|
| 340 |
__ https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols |
| 341 |
__ https://developer.mozilla.org/en-US/docs/Web/MathML/Attribute |
| 342 |
|
| 343 |
Additional alphabets are defined in LaTeX packages, e.g. |
| 344 |
|
| 345 |
.. class:: colwidths-auto |
| 346 |
|
| 347 |
=========== ============= ====================== |
| 348 |
TeX command LaTeX package MathML "mathvariant" |
| 349 |
=========== ============= ====================== |
| 350 |
mathbfit isomath_ bold-italic |
| 351 |
mathsfit isomath_ sans-serif-italic |
| 352 |
mathsfbfit isomath_ sans-serif-bold-italic |
| 353 |
mathscr mathrsfs_ script |
| 354 |
=========== ============= ====================== |
| 355 |
.. _isomath: https://www.ctan.org/pkg/isomath |
| 356 |
.. _mathrsfs: https://www.ctan.org/pkg/mathrsfs |
| 357 |
|
| 358 |
This can be used to typeset vector symbols in bold italic |
| 359 |
in line with the International Standard [ISO-80000-2]. |
| 360 |
|
| 361 |
.. ``\mathbfit{r}^2=x^2+y^2+z^2`` becomes |
| 362 |
|
| 363 |
.. math:: \mathbfit{r}^2=x^2+y^2+z^2. |
| 364 |
|
| 365 |
The package mathrsfs_ (and some drop-in replacements) define the ``\mathscr`` |
| 366 |
macro that selects a differently shaped "script" alphabet. |
| 367 |
Compare `\mathscr{A, B, …, Z, a, b, …, z}` |
| 368 |
with `\mathcal{A, B, …, Z, a, b, …, z}`. |
| 369 |
|
| 370 |
|
| 371 |
In contrast to the math alphabet selectors, ``\boldsymbol`` only changes |
| 372 |
the *font weight*. In LaTeX, it can be used to get a bold version of any |
| 373 |
mathematical symbol (for other output formats, results are mixed): |
| 374 |
|
| 375 |
.. math:: |
| 376 |
\boldsymbol{\cos(x)\pm\alpha \approx 3\Gamma \quad \forall x\in\mathbb{R}} |
| 377 |
|
| 378 |
|
| 379 |
Miscellaneous symbols |
| 380 |
--------------------- |
| 381 |
.. class:: colwidths-auto |
| 382 |
|
| 383 |
==================== ====================== ================ ================== ================= =================== |
| 384 |
`\#` ``\#`` `\clubsuit` ``\clubsuit`` `\neg` ``\neg`` |
| 385 |
`\&` ``\&`` `\diamondsuit` ``\diamondsuit`` `\nexists` ``\nexists`` |
| 386 |
`\angle` ``\angle`` `\emptyset` ``\emptyset`` `\prime` ``\prime`` |
| 387 |
`\backprime` ``\backprime`` `\exists` ``\exists`` `\sharp` ``\sharp`` |
| 388 |
`\bigstar` ``\bigstar`` `\flat` ``\flat`` `\spadesuit` ``\spadesuit`` |
| 389 |
`\blacklozenge` ``\blacklozenge`` `\forall` ``\forall`` `\sphericalangle` ``\sphericalangle`` |
| 390 |
`\blacksquare` ``\blacksquare`` `\heartsuit` ``\heartsuit`` `\square` ``\square`` |
| 391 |
`\blacktriangle` ``\blacktriangle`` `\infty` ``\infty`` `\surd` ``\surd`` |
| 392 |
`\blacktriangledown` ``\blacktriangledown`` `\lozenge` ``\lozenge`` `\top` ``\top`` |
| 393 |
`\bot` ``\bot`` `\measuredangle` ``\measuredangle`` `\triangle` ``\triangle`` |
| 394 |
`\diagdown` ``\diagdown`` `\nabla` ``\nabla`` `\triangledown` ``\triangledown`` |
| 395 |
`\diagup` ``\diagup`` `\natural` ``\natural`` `\varnothing` ``\varnothing`` |
| 396 |
==================== ====================== ================ ================== ================= =================== |
| 397 |
|
| 398 |
|
| 399 |
Punctuation |
| 400 |
----------- |
| 401 |
.. class:: colwidths-auto |
| 402 |
|
| 403 |
=== ===== ======== =============== ======== ========== |
| 404 |
`.` ``.`` `!` ``!`` `\vdots` ``\vdots`` |
| 405 |
`/` ``/`` `?` ``?`` `\dotsb` ``\dotsb`` |
| 406 |
`|` ``|`` `\colon` ``\colon`` [#]_ `\dotsc` ``\dotsc`` |
| 407 |
`'` ``'`` `\cdots` ``\cdots`` `\dotsi` ``\dotsi`` |
| 408 |
`;` ``;`` `\ddots` ``\ddots`` `\dotsm` ``\dotsm`` |
| 409 |
`:` ``:`` `\ldots` ``\ldots`` `\dotso` ``\dotso`` |
| 410 |
=== ===== ======== =============== ======== ========== |
| 411 |
|
| 412 |
.. [#] Punctuation (not ratio): |
| 413 |
Compare spacing in `a\colon b\to c` to `a:b = c`. |
| 414 |
|
| 415 |
Relation symbols |
| 416 |
---------------- |
| 417 |
|
| 418 |
Arrows |
| 419 |
~~~~~~ |
| 420 |
.. class:: colwidths-auto |
| 421 |
|
| 422 |
====================== ======================== ===================== ======================= |
| 423 |
`\circlearrowleft` ``\circlearrowleft`` `\circlearrowright` ``\circlearrowright`` |
| 424 |
`\curvearrowleft` ``\curvearrowleft`` `\curvearrowright` ``\curvearrowright`` |
| 425 |
`\hookleftarrow` ``\hookleftarrow`` `\hookrightarrow` ``\hookrightarrow`` |
| 426 |
`\leftarrow` ``\leftarrow`` `\rightarrow` ``\rightarrow`` |
| 427 |
`\Leftarrow` ``\Leftarrow`` `\Rightarrow` ``\Rightarrow`` |
| 428 |
`\leftarrowtail` ``\leftarrowtail`` `\rightarrowtail` ``\rightarrowtail`` |
| 429 |
`\leftharpoondown` ``\leftharpoondown`` `\rightharpoondown` ``\rightharpoondown`` |
| 430 |
`\leftharpoonup` ``\leftharpoonup`` `\rightharpoonup` ``\rightharpoonup`` |
| 431 |
`\leftleftarrows` ``\leftleftarrows`` `\rightrightarrows` ``\rightrightarrows`` |
| 432 |
`\leftrightarrow` ``\leftrightarrow`` `\Leftrightarrow` ``\Leftrightarrow`` |
| 433 |
`\leftrightarrows` ``\leftrightarrows`` `\rightleftarrows` ``\rightleftarrows`` |
| 434 |
`\leftrightharpoons` ``\leftrightharpoons`` `\rightleftharpoons` ``\rightleftharpoons`` |
| 435 |
`\leftrightsquigarrow` ``\leftrightsquigarrow`` `\rightsquigarrow` ``\rightsquigarrow`` |
| 436 |
`\Lleftarrow` ``\Lleftarrow`` `\Rrightarrow` ``\Rrightarrow`` |
| 437 |
`\longleftarrow` ``\longleftarrow`` `\longrightarrow` ``\longrightarrow`` |
| 438 |
`\Longleftarrow` ``\Longleftarrow`` `\Longrightarrow` ``\Longrightarrow`` |
| 439 |
`\longleftrightarrow` ``\longleftrightarrow`` `\Longleftrightarrow` ``\Longleftrightarrow`` |
| 440 |
`\looparrowleft` ``\looparrowleft`` `\looparrowright` ``\looparrowright`` |
| 441 |
`\Lsh` ``\Lsh`` `\Rsh` ``\Rsh`` |
| 442 |
`\mapsto` ``\mapsto`` `\longmapsto` ``\longmapsto`` |
| 443 |
`\multimap` ``\multimap`` |
| 444 |
`\nleftarrow` ``\nleftarrow`` `\nrightarrow` ``\nrightarrow`` |
| 445 |
`\nLeftarrow` ``\nLeftarrow`` `\nRightarrow` ``\nRightarrow`` |
| 446 |
`\nleftrightarrow` ``\nleftrightarrow`` `\nLeftrightarrow` ``\nLeftrightarrow`` |
| 447 |
`\nwarrow` ``\nwarrow`` `\nearrow` ``\nearrow`` |
| 448 |
`\swarrow` ``\swarrow`` `\searrow` ``\searrow`` |
| 449 |
`\twoheadleftarrow` ``\twoheadleftarrow`` `\twoheadrightarrow` ``\twoheadrightarrow`` |
| 450 |
`\upharpoonleft` ``\upharpoonleft`` `\upharpoonright` ``\upharpoonright`` |
| 451 |
`\downharpoonleft` ``\downharpoonleft`` `\downharpoonright` ``\downharpoonright`` |
| 452 |
`\upuparrows` ``\upuparrows`` `\downdownarrows` ``\downdownarrows`` |
| 453 |
====================== ======================== ===================== ======================= |
| 454 |
|
| 455 |
Synonyms: `\gets` ``\gets``, `\to` ``\to``, `\restriction` ``\restriction``. |
| 456 |
|
| 457 |
Comparison |
| 458 |
~~~~~~~~~~ |
| 459 |
|
| 460 |
.. class:: colwidths-auto |
| 461 |
|
| 462 |
================ ================== ============= =============== ============= =============== =============== ================= |
| 463 |
`<` ``<`` `\geq` ``\geq`` `\ll` ``\ll`` `\prec` ``\prec`` |
| 464 |
`=` ``=`` `\geqq` ``\geqq`` `\lll` ``\lll`` `\precapprox` ``\precapprox`` |
| 465 |
`>` ``>`` `\geqslant` ``\geqslant`` `\lnapprox` ``\lnapprox`` `\preccurlyeq` ``\preccurlyeq`` |
| 466 |
`\approx` ``\approx`` `\gg` ``\gg`` `\lneq` ``\lneq`` `\preceq` ``\preceq`` |
| 467 |
`\approxeq` ``\approxeq`` `\ggg` ``\ggg`` `\lneqq` ``\lneqq`` `\precnapprox` ``\precnapprox`` |
| 468 |
`\asymp` ``\asymp`` `\gnapprox` ``\gnapprox`` `\lnsim` ``\lnsim`` `\precneqq` ``\precneqq`` |
| 469 |
`\backsim` ``\backsim`` `\gneq` ``\gneq`` `\ncong` ``\ncong`` `\precnsim` ``\precnsim`` |
| 470 |
`\backsimeq` ``\backsimeq`` `\gneqq` ``\gneqq`` `\neq` ``\neq`` `\precsim` ``\precsim`` |
| 471 |
`\bumpeq` ``\bumpeq`` `\gnsim` ``\gnsim`` `\ngeq` ``\ngeq`` `\risingdotseq` ``\risingdotseq`` |
| 472 |
`\Bumpeq` ``\Bumpeq`` `\gtrapprox` ``\gtrapprox`` `\ngeqq` ``\ngeqq`` `\sim` ``\sim`` |
| 473 |
`\circeq` ``\circeq`` `\gtreqless` ``\gtreqless`` `\ngeqslant` ``\ngeqslant`` `\simeq` ``\simeq`` |
| 474 |
`\cong` ``\cong`` `\gtreqqless` ``\gtreqqless`` `\ngtr` ``\ngtr`` `\succ` ``\succ`` |
| 475 |
`\curlyeqprec` ``\curlyeqprec`` `\gtrless` ``\gtrless`` `\nleq` ``\nleq`` `\succapprox` ``\succapprox`` |
| 476 |
`\curlyeqsucc` ``\curlyeqsucc`` `\gtrsim` ``\gtrsim`` `\nleqq` ``\nleqq`` `\succcurlyeq` ``\succcurlyeq`` |
| 477 |
`\doteq` ``\doteq`` `\leq` ``\leq`` `\nleqslant` ``\nleqslant`` `\succeq` ``\succeq`` |
| 478 |
`\doteqdot` ``\doteqdot`` `\leqq` ``\leqq`` `\nless` ``\nless`` `\succnapprox` ``\succnapprox`` |
| 479 |
`\eqcirc` ``\eqcirc`` `\leqslant` ``\leqslant`` `\nprec` ``\nprec`` `\succneqq` ``\succneqq`` |
| 480 |
`\eqsim` ``\eqsim`` `\lessapprox` ``\lessapprox`` `\npreceq` ``\npreceq`` `\succnsim` ``\succnsim`` |
| 481 |
`\eqslantgtr` ``\eqslantgtr`` `\lesseqgtr` ``\lesseqgtr`` `\nsim` ``\nsim`` `\succsim` ``\succsim`` |
| 482 |
`\eqslantless` ``\eqslantless`` `\lesseqqgtr` ``\lesseqqgtr`` `\nsucc` ``\nsucc`` `\thickapprox` ``\thickapprox`` |
| 483 |
`\equiv` ``\equiv`` `\lessgtr` ``\lessgtr`` `\nsucceq` ``\nsucceq`` `\thicksim` ``\thicksim`` |
| 484 |
`\fallingdotseq` ``\fallingdotseq`` `\lesssim` ``\lesssim`` `\triangleq` ``\triangleq`` |
| 485 |
================ ================== ============= =============== ============= =============== =============== ================= |
| 486 |
|
| 487 |
The commands ``\lvertneqq`` and ``\gvertneqq`` are not supported by |
| 488 |
LateX2MathML, as there is no corresponding Unicode character. |
| 489 |
|
| 490 |
Synonyms: `\ne` ``\ne``, `\le` ``\le``, `\ge` ``\ge``, |
| 491 |
`\Doteq` ``\Doteq``, `\llless` ``\llless``, `\gggtr` ``\gggtr``. |
| 492 |
|
| 493 |
Symbols can be negated prepending ``\not``, e.g. |
| 494 |
`\not=` ``\not=``, `\not\equiv` ``\not\equiv``, |
| 495 |
`\not\gtrless` ``\not\gtrless``, `\not\lessgtr` ``\not\lessgtr``. |
| 496 |
|
| 497 |
Miscellaneous relations |
| 498 |
~~~~~~~~~~~~~~~~~~~~~~~ |
| 499 |
.. class:: colwidths-auto |
| 500 |
|
| 501 |
===================== ======================= =================== ===================== =================== ===================== |
| 502 |
`\backepsilon` ``\backepsilon`` `\ntrianglelefteq` ``\ntrianglelefteq`` `\subseteq` ``\subseteq`` |
| 503 |
`\because` ``\because`` `\ntriangleright` ``\ntriangleright`` `\subseteqq` ``\subseteqq`` |
| 504 |
`\between` ``\between`` `\ntrianglerighteq` ``\ntrianglerighteq`` `\subsetneq` ``\subsetneq`` |
| 505 |
`\blacktriangleleft` ``\blacktriangleleft`` `\nvdash` ``\nvdash`` `\subsetneqq` ``\subsetneqq`` |
| 506 |
`\blacktriangleright` ``\blacktriangleright`` `\nVdash` ``\nVdash`` `\supset` ``\supset`` |
| 507 |
`\bowtie` ``\bowtie`` `\nvDash` ``\nvDash`` `\Supset` ``\Supset`` |
| 508 |
`\dashv` ``\dashv`` `\nVDash` ``\nVDash`` `\supseteq` ``\supseteq`` |
| 509 |
`\frown` ``\frown`` `\parallel` ``\parallel`` `\supseteqq` ``\supseteqq`` |
| 510 |
`\in` ``\in`` `\perp` ``\perp`` `\supsetneq` ``\supsetneq`` |
| 511 |
`\mid` ``\mid`` `\pitchfork` ``\pitchfork`` `\supsetneqq` ``\supsetneqq`` |
| 512 |
`\models` ``\models`` `\propto` ``\propto`` `\therefore` ``\therefore`` |
| 513 |
`\ni` ``\ni`` `\shortmid` ``\shortmid`` `\trianglelefteq` ``\trianglelefteq`` |
| 514 |
`\nmid` ``\nmid`` `\shortparallel` ``\shortparallel`` `\trianglerighteq` ``\trianglerighteq`` |
| 515 |
`\notin` ``\notin`` `\smallfrown` ``\smallfrown`` `\varpropto` ``\varpropto`` |
| 516 |
`\nparallel` ``\nparallel`` `\smallsmile` ``\smallsmile`` `\vartriangle` ``\vartriangle`` |
| 517 |
`\nshortmid` ``\nshortmid`` `\smile` ``\smile`` `\vartriangleleft` ``\vartriangleleft`` |
| 518 |
`\nshortparallel` ``\nshortparallel`` `\sqsubset` ``\sqsubset`` `\vartriangleright` ``\vartriangleright`` |
| 519 |
`\nsubseteq` ``\nsubseteq`` `\sqsubseteq` ``\sqsubseteq`` `\vdash` ``\vdash`` |
| 520 |
`\nsubseteqq` ``\nsubseteqq`` `\sqsupset` ``\sqsupset`` `\Vdash` ``\Vdash`` |
| 521 |
`\nsupseteq` ``\nsupseteq`` `\sqsupseteq` ``\sqsupseteq`` `\vDash` ``\vDash`` |
| 522 |
`\nsupseteqq` ``\nsupseteqq`` `\subset` ``\subset`` `\Vvdash` ``\Vvdash`` |
| 523 |
`\ntriangleleft` ``\ntriangleleft`` `\Subset` ``\Subset`` |
| 524 |
===================== ======================= =================== ===================== =================== ===================== |
| 525 |
|
| 526 |
Synonyms: `\owns` ``\owns``. |
| 527 |
|
| 528 |
Symbols can be negated prepending ``\not``, e.g. |
| 529 |
`\not\in` ``\not\in``, `\not\ni` ``\not\ni``. |
| 530 |
|
| 531 |
The commands ``\varsubsetneq``, ``\varsubsetneqq``, ``\varsupsetneq``, |
| 532 |
and ``\varsupsetneqq`` are not supported by LateX2MathML, as there is no |
| 533 |
corresponding Unicode character. |
| 534 |
|
| 535 |
Variable-sized operators |
| 536 |
------------------------ |
| 537 |
.. class:: colwidths-auto |
| 538 |
|
| 539 |
========================= ========================= ========================= =========================== |
| 540 |
`\sum` ``\sum`` `\prod` ``\prod`` `\bigcap` ``\bigcap`` `\bigodot` ``\bigodot`` |
| 541 |
`\int` ``\int`` `\coprod` ``\coprod`` `\bigcup` ``\bigcup`` `\bigoplus` ``\bigoplus`` |
| 542 |
`\oint` ``\oint`` `\bigwedge` ``\bigwedge`` `\biguplus` ``\biguplus`` `\bigotimes` ``\bigotimes`` |
| 543 |
`\smallint` ``\smallint`` `\bigvee` ``\bigvee`` `\bigsqcup` ``\bigsqcup`` |
| 544 |
========================= ========================= ========================= =========================== |
| 545 |
|
| 546 |
Larger symbols are used in displayed formulas, sum-like symbols have |
| 547 |
indices above/below the symbol (see also `scripts and limits`_): |
| 548 |
|
| 549 |
.. math:: \sum_{n=1}^N a_n \qquad |
| 550 |
\int_0^1f(x)\,dx \qquad |
| 551 |
\prod_{i=1}^{10} b_i \ldots |
| 552 |
|
| 553 |
Notations |
| 554 |
========= |
| 555 |
|
| 556 |
Top and bottom embellishments |
| 557 |
----------------------------- |
| 558 |
|
| 559 |
See `Accents and embellishments`_. |
| 560 |
|
| 561 |
Extensible arrows |
| 562 |
----------------- |
| 563 |
|
| 564 |
\xleftarrow and \xrightarrow produce arrows that extend automatically to |
| 565 |
accommodate unusually wide subscripts or superscripts. These commands |
| 566 |
take one optional argument (the subscript) and one mandatory argument |
| 567 |
(the superscript, possibly empty):: |
| 568 |
|
| 569 |
A \xleftarrow{n+\mu-1} B \xrightarrow[T]{n\pm i-1} C |
| 570 |
|
| 571 |
results in |
| 572 |
|
| 573 |
.. math:: A \xleftarrow{n+\mu-1} B \xrightarrow[T]{n\pm i-1} C |
| 574 |
|
| 575 |
Affixing symbols to other symbols |
| 576 |
--------------------------------- |
| 577 |
|
| 578 |
In addition to the standard `accents and embellishments`_, other symbols |
| 579 |
can be placed above or below a base symbol with the ``\overset`` and |
| 580 |
``\underset`` commands. The symbol is set in "scriptstyle" (smaller font |
| 581 |
size). For example, writing ``\overset{*}{X}`` becomes `\overset{*}{X}` |
| 582 |
and ``\underset{+}{M}`` becomes `\underset{+}{M}`. |
| 583 |
|
| 584 |
|
| 585 |
Matrices |
| 586 |
-------- |
| 587 |
|
| 588 |
The ``matrix`` and ``cases`` environments can also contain ``\\`` and |
| 589 |
``&``:: |
| 590 |
|
| 591 |
.. math:: |
| 592 |
\left ( \begin{matrix} a & b \\ c & d \end{matrix}\right) |
| 593 |
|
| 594 |
Result: |
| 595 |
|
| 596 |
.. math:: |
| 597 |
\left ( \begin{matrix} a & b \\ c & d \end{matrix} \right) |
| 598 |
|
| 599 |
The environments ``pmatrix``, ``bmatrix``, ``Bmatrix``, ``vmatrix``, and |
| 600 |
``Vmatrix`` have (respectively) ( ), [ ], { }, \| \|, and `\Vert\ \Vert` |
| 601 |
delimiters built in, e.g. |
| 602 |
|
| 603 |
.. math:: \begin{pmatrix} a & b \\ c & d \end{pmatrix} \qquad |
| 604 |
\begin{bmatrix} a & b \\ c & d \end{bmatrix} \qquad |
| 605 |
\begin{Vmatrix} a & b \\ c & d \end{Vmatrix} |
| 606 |
|
| 607 |
To produce a small matrix suitable for use in text, there is a |
| 608 |
``smallmatrix`` environment |
| 609 |
`\bigl(\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}\bigr)` |
| 610 |
that comes closer to fitting within a single text line than a normal |
| 611 |
matrix. |
| 612 |
|
| 613 |
|
| 614 |
For piecewise function definitions there is a ``cases`` environment: |
| 615 |
|
| 616 |
.. math:: \mathrm{sgn}(x) = \begin{cases} |
| 617 |
-1 & x<0\\ |
| 618 |
\phantom{-}1 & x>0 |
| 619 |
\end{cases} |
| 620 |
|
| 621 |
Spacing commands |
| 622 |
---------------- |
| 623 |
|
| 624 |
Horizontal spacing of elements can be controlled with the following |
| 625 |
commands: |
| 626 |
|
| 627 |
.. class:: colwidths-auto |
| 628 |
|
| 629 |
====================== ======== ===================== ================== |
| 630 |
:m:`3\qquad 4` ``3\qquad 4`` = 2em |
| 631 |
:m:`3\quad 4` ``3\quad 4`` = 1em |
| 632 |
:m:`3~4` ``3~4`` ``3\nobreakspace 4`` |
| 633 |
:m:`3\ 4` ``3\ 4`` escaped space |
| 634 |
:m:`3\;4` ``3\;4`` ``3\thickspace 4`` |
| 635 |
:m:`3\:4` ``3\:4`` ``3\medspace 4`` |
| 636 |
:m:`3\,4` ``3\,4`` ``3\thinspace 4`` |
| 637 |
:m:`3 4` ``3 4`` regular space [#]_ |
| 638 |
:m:`3\!4` ``3\!4`` ``3\negthinspace 4`` |
| 639 |
:m:`3\negmedspace 4` ``3\negmedspace 4`` |
| 640 |
:m:`3\negthickspace 4` ``3\negthickspace 4`` |
| 641 |
`3\hspace{1ex}4` ``3\hspace{1ex}4`` custom length |
| 642 |
`3\mspace{20mu}4` ``3\mspace{20mu}4`` custom length [#]_ |
| 643 |
====================== ======== ===================== ================== |
| 644 |
|
| 645 |
.. [#] Whitespace characters are ignored in LaTeX math mode. |
| 646 |
.. [#] Unit must be 'mu' (1 mu = 1/18em). |
| 647 |
|
| 648 |
Negative spacing does not work with MathML (in Firefox 78). |
| 649 |
|
| 650 |
There are also three commands that leave a space equal to the height and |
| 651 |
width of its argument. For example ``\phantom{XXX}`` results in space as |
| 652 |
wide and high as three X’s: |
| 653 |
|
| 654 |
.. math:: \frac{\phantom{XXX}+1}{XXX-1} |
| 655 |
|
| 656 |
The commands ``\hphantom`` and ``\vphantom`` insert space with the |
| 657 |
width or height of the argument. They are not supported with `math_output`_ |
| 658 |
MathML. |
| 659 |
|
| 660 |
Roots |
| 661 |
----- |
| 662 |
|
| 663 |
.. class:: colwidths-auto |
| 664 |
|
| 665 |
========= ==================== ================== |
| 666 |
command example result |
| 667 |
========= ==================== ================== |
| 668 |
``\sqrt`` ``\sqrt{x^2-1}`` `\sqrt{x^2-1}` |
| 669 |
.. ``\sqrt[3n]{x^2-1}`` `\sqrt[3n]{x^2-1}` |
| 670 |
.. ``\sqrt\frac{1}{2}`` `\sqrt\frac{1}{2}` |
| 671 |
========= ==================== ================== |
| 672 |
|
| 673 |
Boxed formulas |
| 674 |
-------------- |
| 675 |
|
| 676 |
The command ``\boxed`` puts a box around its argument: |
| 677 |
|
| 678 |
.. math:: \boxed{\eta \leq C(\delta(\eta) +\Lambda_M(0,\delta))} |
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
Fractions and related constructions |
| 683 |
=================================== |
| 684 |
|
| 685 |
The ``\frac`` command takes two ar guments, numerator and denominator, |
| 686 |
and typesets them in normal fraction form. For example, ``U = \frac{R}{I}`` |
| 687 |
produces `U = \frac{R}{I}`. Use ``\dfrac`` or ``\tfrac`` to |
| 688 |
force text style and display style respectively. |
| 689 |
|
| 690 |
.. math:: \frac{x+1}{x-1} \quad |
| 691 |
\dfrac{x+1}{x-1} \quad |
| 692 |
\tfrac{x+1}{x-1} |
| 693 |
|
| 694 |
and in text: `\frac{x+1}{x-1}`, `\dfrac{x+1}{x-1}`, `\tfrac{x+1}{x-1}`. |
| 695 |
|
| 696 |
For binomial expressions such as `\binom{n}{k}`, |
| 697 |
there are ``\binom``, ``\dbinom`` and ``\tbinom`` commands:: |
| 698 |
|
| 699 |
2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2} |
| 700 |
|
| 701 |
prints |
| 702 |
|
| 703 |
.. math:: 2^k-\binom{k}{1}2^{k-1}+\binom{k}{2}2^{k-2} |
| 704 |
|
| 705 |
The ``\cfrac`` command for continued fractions uses displaystyle and |
| 706 |
padding for sub-fractions: |
| 707 |
|
| 708 |
.. math:: \frac{\pi}{4} = 1 + \cfrac{1^2}{ |
| 709 |
2 + \cfrac{3^2}{ |
| 710 |
2 + \cfrac{5^2}{ |
| 711 |
2 + \cfrac{7^2}{2 + \cdots} |
| 712 |
}}} |
| 713 |
\qquad \text{vs.}\qquad |
| 714 |
\frac{\pi}{4} = 1 + \frac{1^2}{ |
| 715 |
2 + \frac{3^2}{ |
| 716 |
2 + \frac{5^2}{ |
| 717 |
2 + \frac{7^2}{2 + \cdots} |
| 718 |
}}} |
| 719 |
|
| 720 |
It supports the optional argument ``[l]`` or ``[r]`` for |
| 721 |
left or right placement of the numerator: |
| 722 |
|
| 723 |
.. math:: \cfrac[l]{x}{x-1} \quad |
| 724 |
\cfrac{x}{x-1} \quad |
| 725 |
\cfrac[r]{x}{x-1} |
| 726 |
|
| 727 |
|
| 728 |
Delimiter sizes |
| 729 |
=============== |
| 730 |
|
| 731 |
Besides the automatic scaling of `extensible delimiters`_ with ``\left`` |
| 732 |
and ``\right``, there are four commands to manually select delimiters of |
| 733 |
fixed size: |
| 734 |
|
| 735 |
.. class:: colwidths-auto |
| 736 |
|
| 737 |
========= ============== ============== ============== ============== =============== =============== |
| 738 |
Sizing no ``\left`` ``\bigl`` ``\Bigl`` ``\biggl`` ``\Biggl`` |
| 739 |
command ``\right`` ``\bigr`` ``\Bigr`` ``\biggr`` ``\Biggr`` |
| 740 |
--------- -------------- -------------- -------------- -------------- --------------- --------------- |
| 741 |
Result `\displaystyle `\displaystyle `\displaystyle `\displaystyle `\displaystyle `\displaystyle |
| 742 |
(b) \left(b\right) \bigl(b\bigr) \Bigl(b\Bigr) \biggl(b\biggr) \Biggl(b\Biggr) |
| 743 |
(\frac{c}{d})` \left(\frac{c} \bigl(\frac{c} \Bigl(\frac{c} \biggl(\frac{c} \Biggl(\frac{c} |
| 744 |
{d}\right)` {d}\bigr)` {d}\Bigr)` {d}\biggr)` {d}\Biggr)` |
| 745 |
========= ============== ============== ============== ============== =============== =============== |
| 746 |
|
| 747 |
There are two or three situations where the delimiter size is commonly |
| 748 |
adjusted using these commands: |
| 749 |
|
| 750 |
The first kind of adjustment is done for cumulative operators with |
| 751 |
limits, such as summation signs. With ``\left`` and ``\right`` the |
| 752 |
delimiters usually turn out larger than necessary, and using the ``Big`` |
| 753 |
or ``bigg`` sizes instead gives better results: |
| 754 |
|
| 755 |
.. math:: |
| 756 |
\left[\sum_i a_i\left\lvert\sum_j x_{ij}\right\rvert^p\right]^{1/p} |
| 757 |
\text{ versus } |
| 758 |
\biggl[\sum_i a_i\Bigl\lvert\sum_j x_{ij}\Bigr\rvert^p\biggr]^{1/p} |
| 759 |
|
| 760 |
The second kind of situation is clustered pairs of delimiters, where |
| 761 |
\left and \right make them all the same size (because that is adequate to |
| 762 |
cover the encompassed material), but what you really want is to make some |
| 763 |
of the delimiters slightly larger to make the nesting easier to see. |
| 764 |
|
| 765 |
.. math:: \left((a_1 b_1) - (a_2 b_2)\right) |
| 766 |
\left((a_2 b_1) + (a_1 b_2)\right) |
| 767 |
\quad\text{versus}\quad |
| 768 |
\bigl((a_1 b_1) - (a_2 b_2)\bigr) |
| 769 |
\bigl((a_2 b_1) + (a_1 b_2)\bigr) |
| 770 |
|
| 771 |
The third kind of situation is a slightly oversize object in running |
| 772 |
text, such as `\left|\frac{b'}{d'}\right|` where the delimiters produced |
| 773 |
by ``\left`` and ``\right`` cause too much line spreading. [#]_ In that case |
| 774 |
``\bigl`` and ``\bigr`` can be used to produce delimiters that are larger |
| 775 |
than the base size but still able to fit within the normal line spacing: |
| 776 |
`\bigl|\frac{b'}{d'}\bigr|`. |
| 777 |
|
| 778 |
.. [#] With MathML, an example would be parentheses |
| 779 |
around a ``smallmatrix`` environment |
| 780 |
`\left(\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}\right)` |
| 781 |
vs. `\Bigl(\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}\Bigr)`. |
| 782 |
|
| 783 |
Text |
| 784 |
==== |
| 785 |
|
| 786 |
The main use of the command ``\text`` is for words or phrases in a |
| 787 |
display. It is similar to ``\mbox`` in its effects but, unlike ``\mbox``, |
| 788 |
automatically produces subscript-size text if used in a subscript, |
| 789 |
``k_{\text{B}}T`` becomes `k_{\text{B}}T`. |
| 790 |
|
| 791 |
Whitespace is kept inside the argument: |
| 792 |
|
| 793 |
.. Math:: f_{[x_{i-1},x_i]} \text{ is monotonic for } i = 1,\,…,\,c+1 |
| 794 |
|
| 795 |
|
| 796 |
The text may contain math commands wrapped in ``$`` signs, e.g. |
| 797 |
|
| 798 |
.. math:: (-1)^{n_i} = \begin{cases} -1 \quad \text{if $n_i$ is odd,} \\ |
| 799 |
+1 \quad \text{if $n_i$ is even.} |
| 800 |
\end{cases} |
| 801 |
|
| 802 |
.. TODO ignore {}, handle text-mode commands |
| 803 |
|
| 804 |
|
| 805 |
.. TODO: ``\mod`` and its relatives |
| 806 |
-------------------------- |
| 807 |
|
| 808 |
Commands ``\mod``, ``\bmod``, ``\pmod``, ``\pod`` deal with the special |
| 809 |
spacing conventions of “mod” notation. ``\mod`` and ``\pod`` are |
| 810 |
variants of ``\pmod`` preferred by some authors; ``\mod`` omits the |
| 811 |
parentheses, whereas ``\pod`` omits the “mod” and retains the |
| 812 |
parentheses. |
| 813 |
|
| 814 |
\gcd(n,m\bmod n) ;\quad x\equiv y\pmod b |
| 815 |
;\quad x\equiv y\mod c ;\quad x\equiv y\pod d |
| 816 |
|
| 817 |
|
| 818 |
Integrals and sums |
| 819 |
================== |
| 820 |
|
| 821 |
The limits on integrals, sums, and similar symbols are placed either to |
| 822 |
the side of or above and below the base symbol, depending on convention |
| 823 |
and context. In inline formulas and fractions, the limits on sums, and |
| 824 |
similar symbols like |
| 825 |
|
| 826 |
.. math:: \lim_{n\to\infty} \sum_1^n \frac{1}{n} |
| 827 |
|
| 828 |
move to index positions: `\lim_{n\to\infty} \sum_1^n \frac{1}{n}`. |
| 829 |
|
| 830 |
Altering the placement of limits |
| 831 |
-------------------------------- |
| 832 |
|
| 833 |
The commands ``\intop`` and ``\ointop`` produce integral signs with |
| 834 |
limits as in sums and similar: `\intop_0^1`, `\ointop_c` and |
| 835 |
|
| 836 |
.. math:: \intop_0^1 \quad \ointop_c |
| 837 |
\quad \text{vs.} \quad |
| 838 |
\int^1_0 \quad \oint_c |
| 839 |
|
| 840 |
The commands ``\limits`` and ``\nolimits`` override the default placement |
| 841 |
of the limits for any operator; ``\displaylimits`` forces standard |
| 842 |
positioning as for the \sum command. They should follow immediately after |
| 843 |
the operator to which they apply. |
| 844 |
|
| 845 |
Compare the same term with default positions, ``\limits``, and |
| 846 |
``\nolimits`` in inline and display mode: `\lim_{x\to0}f(x)`, |
| 847 |
`\lim\limits_{x\to0}f(x)`, `\lim\nolimits_{x\to0}f(x)`, vs. |
| 848 |
|
| 849 |
.. math:: \lim_{x\to0}f(x), \quad |
| 850 |
\lim\limits_{x\to0}f(x) \quad |
| 851 |
\lim\nolimits_{x\to0}f(x). |
| 852 |
|
| 853 |
.. TODO: \substack |
| 854 |
|
| 855 |
.. TODO: \sideset |
| 856 |
|
| 857 |
|
| 858 |
Changing the size of elements in a formula |
| 859 |
========================================== |
| 860 |
|
| 861 |
The declarations [#]_ ``\displaystyle``, ``\textstyle``, |
| 862 |
``\scriptstyle``, and ``\scriptscriptstyle``, select a symbol size and |
| 863 |
spacing that would be applied in (respectively) display math, inline |
| 864 |
math, first-order subscript, or second-order subscript, even when the |
| 865 |
current context would normally yield some other size. |
| 866 |
|
| 867 |
For example ``:math:`\displaystyle \sum_{n=0}^\infty |
| 868 |
\frac{1}{n}``` is printed as `\displaystyle \sum_{n=0}^\infty \frac{1}{n}` |
| 869 |
rather than `\sum_{n=0}^\infty \frac{1}{n}` and :: |
| 870 |
|
| 871 |
\frac{\scriptstyle\sum_{n > 0} z^n} |
| 872 |
{\displaystyle\prod_{1\leq k\leq n} (1-q^k)} |
| 873 |
|
| 874 |
yields |
| 875 |
|
| 876 |
.. math:: |
| 877 |
|
| 878 |
\frac{\scriptstyle\sum_{n > 0} z^n} |
| 879 |
{\displaystyle\prod_{1\leq k\leq n} (1-q^k)} |
| 880 |
\text{ instead of the default } |
| 881 |
\frac{\sum_{n > 0} z^n} |
| 882 |
{\prod_{1\leq k\leq n} (1-q^k)}. |
| 883 |
|
| 884 |
.. [#] "Declarations" are commands that affect processing of the current |
| 885 |
"group". In particular, notice where the braces fall that delimit the |
| 886 |
effect of the command: Right: ``{\displaystyle ...}`` Wrong: |
| 887 |
``\displaystyle{...}``. |
| 888 |
|
| 889 |
With math_output_ MathML, the declaration must be the first element |
| 890 |
after the opening bracket. |
| 891 |
|
| 892 |
|
| 893 |
Appendix |
| 894 |
======== |
| 895 |
|
| 896 |
Tests |
| 897 |
----- |
| 898 |
|
| 899 |
|
| 900 |
Font changes |
| 901 |
~~~~~~~~~~~~ |
| 902 |
|
| 903 |
Math alphabet macros change the default alphabet ("mathvariant" in |
| 904 |
MathML), leaving some symbols unchanged: |
| 905 |
|
| 906 |
:normal: `abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R` |
| 907 |
:mathrm: `\mathrm{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}` |
| 908 |
:mathit: `\mathit{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}` |
| 909 |
:mathsf: `\mathsf{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}` |
| 910 |
:mathbb: `\mathbb{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}` |
| 911 |
:mathbf: `\mathbf{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}` |
| 912 |
:mathcal: `\mathcal{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}` |
| 913 |
:mathscr: `\mathscr{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}` |
| 914 |
|
| 915 |
Unicode supports the following blackboard-bold characters: |
| 916 |
`\mathbb{a \ldots z A \ldots Z 0 \ldots 9 |
| 917 |
\mathbb\Gamma \mathbb{\Pi} \mathbb {\Sigma} \mathbb\gamma \mathbb\pi}`. |
| 918 |
|
| 919 |
|
| 920 |
Inferred <mrow>s in MathML |
| 921 |
~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 922 |
|
| 923 |
The elements <msqrt>, <mstyle>, <merror>, <mpadded>, <mphantom>, <menclose>, |
| 924 |
<mtd>, <mscarry>, and <math> treat their contents as a single inferred mrow |
| 925 |
formed from all their children. |
| 926 |
|
| 927 |
.. math:: a = \sqrt 2 + x,\quad |
| 928 |
b = \sqrt{1+x^2},\quad |
| 929 |
c = \sqrt\frac{\sin(x)}{23}, |
| 930 |
|
| 931 |
inline: :math:`a = \sqrt 2 + x, b = \sqrt{1+x^2}, c = \sqrt\frac{\sin(x)}{23}`. |
| 932 |
|
| 933 |
|
| 934 |
Scripts and Limits |
| 935 |
~~~~~~~~~~~~~~~~~~ |
| 936 |
|
| 937 |
Accents should be nearer to the base (in MathML Firefox 78, it's vice versa!): |
| 938 |
`\bar a \overline a, \bar l \overline l, \bar i \overline i`, |
| 939 |
`\vec{r}` `\overrightarrow{r}`. |
| 940 |
|
| 941 |
Sub- and superscript may be given in any order: |
| 942 |
`x_i^j = x^j_i` and `\int_0^1 = \int^1_0`. |
| 943 |
|
| 944 |
Double exponent: `x^{10^4}`, `r_{T_\mathrm{in}}` and `x_i^{n^2}`. |
| 945 |
|
| 946 |
|
| 947 |
Nested groups |
| 948 |
~~~~~~~~~~~~~ |
| 949 |
|
| 950 |
tex-token returns "{" for nested groups: |
| 951 |
|
| 952 |
.. math:: \text{das ist ein {toller} text (unescaped \{ and \} is |
| 953 |
ignored by LaTeX)} |
| 954 |
|
| 955 |
Big delimiters and symbols |
| 956 |
~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 957 |
Compare automatic sizing with fixed sizes: |
| 958 |
|
| 959 |
.. math: \left( \frac{\frac1x}{\frac{1}{n}}\right) &= \Biggl(\text{Bigg}\Biggr)\\ |
| 960 |
|
| 961 |
|
| 962 |
.. math:: |
| 963 |
\left( 3 \right) |
| 964 |
\left( f(x) \right) |
| 965 |
\left( \bar x \right) |
| 966 |
\left( \overline x \right) |
| 967 |
\left( n_i \right) &= () \\ |
| 968 |
\left( \underline x \right) &= \bigl(\text{big}\bigr)\\ |
| 969 |
\left( 3^2 \right) |
| 970 |
\left( \sqrt{3} \right) |
| 971 |
\left( \sqrt{3^2} \right) |
| 972 |
\left( \sum \right) |
| 973 |
\left( \bigotimes \right) |
| 974 |
\left( \prod \right) &= \Bigl(\text{Big}\Bigr)\\ |
| 975 |
\left( \frac{3 }{2} \right) |
| 976 |
\left( \frac{3^2}{2^4} \right) |
| 977 |
\binom{3 }{2} |
| 978 |
\begin{pmatrix} a & b \\ c & d \end{pmatrix} |
| 979 |
\left( \frac{1}{\sqrt 2} \right) |
| 980 |
\left( \int \right) |
| 981 |
\left( \int_0 \right) |
| 982 |
\left( \int^1 \right) |
| 983 |
\left( \int_0^1 \right) &= \biggl(\text{bigg}\biggr)\\ |
| 984 |
\left( \frac{\sqrt 2}{2} \right) |
| 985 |
\left( \sum_0 \right) |
| 986 |
\left( \sum^1 \right) |
| 987 |
\left( \sum_0^1 \right) |
| 988 |
\left( \frac{\frac1x}{\frac{1}{n}}\right) &= \Biggl(\text{Bigg}\Biggr)\\ |
| 989 |
\left( \intop_0 \right) |
| 990 |
\left( \intop^1 \right) |
| 991 |
\left( \intop_0^1 \right) |
| 992 |
|
| 993 |
And in text: |
| 994 |
|
| 995 |
:`()`: `\left(3 \right) |
| 996 |
\left( f(x) \right) |
| 997 |
\left( \bar x \right) |
| 998 |
\left( \overline x \right) |
| 999 |
\left( n_i \right) |
| 1000 |
\left( \sum \right) |
| 1001 |
\left( \sum_0 \right) |
| 1002 |
\left( \prod \right)` |
| 1003 |
|
| 1004 |
|
| 1005 |
:`\bigl(\text{big}\bigr)`: `\left(\underline x \right) |
| 1006 |
\left( 3^2 \right) |
| 1007 |
\binom{3}{2} |
| 1008 |
\left(\begin{smallmatrix} a & b \\ |
| 1009 |
c & d \end{smallmatrix} \right) |
| 1010 |
\left( \bigotimes \right)` |
| 1011 |
|
| 1012 |
:`\Bigl(\text{Big}\Bigr)`: `\left(\sqrt{3} \right) |
| 1013 |
\left( \sqrt{3^2} \right) |
| 1014 |
\left( \frac{3}{2} \right) |
| 1015 |
\left( \frac{3^2}{2^4} \right) |
| 1016 |
\left( \frac{\sqrt 2}{2} \right) |
| 1017 |
\left( \int \right) |
| 1018 |
\left( \int_0 \right) |
| 1019 |
\left( \int^1 \right) |
| 1020 |
\left( \int_0^1 \right) |
| 1021 |
\left( \sum^1 \right) |
| 1022 |
\left( \sum_0^1 \right) |
| 1023 |
\left( \frac{\frac1x}{\frac{1}{n}}\right)` |
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
Test ``\left``, ``\right``, and the \bigl/\bigr, … size commands |
| 1030 |
with all extensible delimiters. |
| 1031 |
|
| 1032 |
.. math:: |
| 1033 |
\left.(b\right)\ \bigl(b\Bigr)\ \biggl(b\Biggr) |
| 1034 |
\quad |
| 1035 |
\left.[b\right]\ \bigl[b\Bigr]\ \biggl[b\Biggr] |
| 1036 |
\quad |
| 1037 |
\left.\{b\right \} \ \bigl\{b\Bigr \} \ \biggl\{b\Biggr \} |
| 1038 |
\quad |
| 1039 |
\left.\langle b\right\rangle\ \bigl\langle b\Bigr\rangle\ \biggl\langle b\Biggr\rangle |
| 1040 |
|
| 1041 |
\left.\lceil b\right\rceil\ \bigl\lceil b\Bigr\rceil\ \biggl\lceil b\Biggr\rceil |
| 1042 |
\quad |
| 1043 |
\left.\lfloor b\right\rfloor\ \bigl\lfloor b\Bigr\rfloor\ \biggl\lfloor b\Biggr\rfloor |
| 1044 |
\quad |
| 1045 |
\left.\lvert b\right\rvert\ \bigl\lvert b\Bigr\rvert\ |
| 1046 |
\biggl\lvert b\Biggr\rvert |
| 1047 |
\quad |
| 1048 |
\left.\lVert b\right\rVert\ \bigl\lVert b\Bigr\rVert\ |
| 1049 |
\biggl\lVert b\Biggr\rVert |
| 1050 |
|
| 1051 |
\left.\lgroup b\right\rgroup\ \bigl\lgroup b\Bigr\rgroup\ \biggl\lgroup b\Biggr\rgroup |
| 1052 |
\quad |
| 1053 |
\left.\lmoustache b\right\rmoustache\ \bigl\lmoustache b\Bigr\rmoustache\ \biggl\lmoustache b\Biggr\rmoustache |
| 1054 |
\quad |
| 1055 |
\left./b\right\backslash\ \bigl/b\Bigr\backslash\ \biggl/b\Biggr\backslash |
| 1056 |
|
| 1057 |
\left.|b\right\|\ \bigl|b\Bigr\|\ \biggl|b\Biggr\| |
| 1058 |
\quad |
| 1059 |
\left.\vert b\right\Vert\ \bigl\vert b\Bigr\Vert\ \biggl\vert b\Biggr\Vert |
| 1060 |
\quad |
| 1061 |
\left.\arrowvert b\right\Arrowvert\ \bigl\arrowvert b\Bigr\Arrowvert\ \biggl\arrowvert b\Biggr\Arrowvert |
| 1062 |
\quad |
| 1063 |
\left.\bracevert b\right\bracevert\ \bigl\bracevert b\Bigr\bracevert\ \biggl\bracevert b\Biggr\bracevert |
| 1064 |
\quad |
| 1065 |
\left.\vert b\right\Vert\ \bigl\vert b\Bigr\Vert\ \biggl\vert b\Biggr\Vert |
| 1066 |
|
| 1067 |
|
| 1068 |
Variable-sized operators: |
| 1069 |
|
| 1070 |
Inline: `\int\ \iint\ \iiint\ \iiiint\ \idotsint \oint\ \smallint\ |
| 1071 |
\sum\ \prod\ \coprod\ \bigwedge\ \bigvee\ \bigcap\ \bigcup\ \biguplus\ |
| 1072 |
\bigsqcup\ \bigodot\ \bigoplus\ \bigotimes` and Display: |
| 1073 |
|
| 1074 |
.. math:: \int\ \iint\ \iiint\ \iiiint\ \idotsint\ \oint\ \smallint\ |
| 1075 |
\sum\ \prod\ \coprod\ \bigwedge\ \bigvee\ \bigcap\ \bigcup\ |
| 1076 |
\biguplus\ \bigsqcup\ \bigodot\ \bigoplus\ \bigotimes |
| 1077 |
|
| 1078 |
.. math:: \int_1 f\ \intop_1 f\ \iint_1 f\ \smallint_1 f\ \sum_1\ |
| 1079 |
\prod_1\ \bigwedge_1\ \bigcap_1\ \biguplus_1\ \bigodot_1\ \int^N\ |
| 1080 |
\intop^N\ \iiiint^N\ \oint^N\ \smallint^N\ \sum^N\ \coprod^N\ |
| 1081 |
\bigvee^N\ \bigcup^N\ \bigsqcup^N\ \bigotimes^N |
| 1082 |
|
| 1083 |
.. math:: \int_1^N\ \intop_1^N\ \iint_1^N\ \iiint_1^N\ \iiiint_1^N\ |
| 1084 |
\idotsint_1^N\ \oint_1^N\ \smallint_1^N\ \sum_1^N\ \prod_1^N\ |
| 1085 |
\coprod_1^N\ \bigwedge_1^N\ \bigvee_1^N\ \bigcap_1^N\ \bigcup_1^N |
| 1086 |
\ \biguplus_1^N\ \bigsqcup_1^N\ \bigodot_1^N\ \bigoplus_1^N\ |
| 1087 |
\bigotimes_1^N |
| 1088 |
|
| 1089 |
|
| 1090 |
Text |
| 1091 |
~~~~ |
| 1092 |
|
| 1093 |
The text may contain non-ASCII characters: `n_\text{Stoß}`. |
| 1094 |
|
| 1095 |
Some text-mode LaTeX commands are supported with math_output_ "html". |
| 1096 |
In other output formats, use literal Unicode: `\text{ç é è ë ê ñ ů ž ©}` |
| 1097 |
to get the result of the accent macros |
| 1098 |
`\text{\c{c} \'e \`e \"e \^e \~n \r{u} \v{z} \textcircled{c}}`. |