Mathematics
HistoryVersion 1 (current)
The first version: all of its text is new.
| 1 | # Mathematics | |
| 2 | ||
| 3 | Between single dollars inline, $e^{i\pi} + 1 = 0$, and between double dollars on a line of their own: | |
| 4 | ||
| 5 | $$ | |
| 6 | \begin{pmatrix} a & b \\ c & d \end{pmatrix}^{-1} | |
| 7 | = \frac{1}{ad - bc} \begin{pmatrix} d & -b \\ -c & a \end{pmatrix} | |
| 8 | $$ | |
| 9 | ||
| 10 | A `math` fence is display math too, and so is a `latex` fence: | |
| 11 | ||
| 12 | ```math | |
| 13 | \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6} | |
| 14 | ``` | |
| 15 | ||
| 16 | ```latex | |
| 17 | \binom{n}{k} = \frac{n!}{k!\,(n-k)!} | |
| 18 | ``` | |
| 19 | ||
| 20 | With `{.norender}` after its language, such a fence shows its TeX as code instead: ` ```latex {.norender} `. | |
| 21 | ||
| 22 | ## Macros | |
| 23 | ||
| 24 | KaTeX has no `\usepackage`, so the wiki has macros instead, in three layers, the nearest winning. Some are built in, for every page: $\abs{x}$, $\norm{v}$, $\floor{x} \le x \le \ceil{x}$, $\Q \subset \R \subset \C$, $\E[X]$ and $\Var(X)$. An administrator keeps them in the administration's **Editor** section, where they can be changed. | |
| 25 | ||
| 26 | This space has its own, in its settings, which its pages and its subspaces' pages may use: $\vect{v} \in V$, $f \in \Hom(V, W)$; and here $\eps$ is $\epsilon$, where the built-in one is $\varepsilon$. | |
| 27 | ||
| 28 | And a formula may define its own, which hold in every formula after it on the page, as in a LaTeX document: | |
| 29 | ||
| 30 | $$ | |
| 31 | \newcommand{\dist}[2]{d\left(#1, #2\right)} | |
| 32 | \dist{x}{z} \le \dist{x}{y} + \dist{y}{z} | |
| 33 | $$ | |
| 34 | ||
| 35 | so that from here on $\dist{x}{x} = 0$. | |
| 36 | ||
| 37 | The editor's **Math macros** button shows them all, and edits the space's (for whoever may edit the whole space) and the page's own block: a `math` block of nothing but definitions under the title, which the page does not show. | |
| 38 | ||
| 39 | ## Chemistry | |
| 40 | ||
| 41 | `\ce` writes chemical formulas and equations (mhchem): $\ce{H2O}$, $\ce{SO4^2-}$, and | |
| 42 | ||
| 43 | $$\ce{CO2 + C -> 2 CO}$$ | |
| 44 | ||
| 45 | $$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$ | |
| 46 | ||
| 47 | and `\pu` quantities with their units: $\pu{123 kJ/mol}$. |