Markdown Overview Buttons Tabs Footnotes Collapse ToC Navigation Formula Page-Specific Meta Custom Components
The Formula
component allows for using math formulas in your docs:
1link> :Formula align=center
2link>
3link> ```
4link> f_n =
5link> \begin{cases}
6link> 1 & \text{if \(n \leq 2\)} \\
7link> f_{n - 1} + f_{n - 2} & \text{otherwise} \\
8link> \end{cases}
9link> ```
You can also use Formula
inline component:
1linkSo lets talk about [\frak{L}_{SM}](:Formula), or lets just do it in
2linkthe last example of the page.
So lets talk about , or lets just do it in the last example of the page.
error IMPORTANT
YOU MUST ENABLE FORMULAS via config to be able to use them. Read the following section to find out how to enable Formulas.
Formulas are not by default plugged into CODEDOC, as they require additional resources.
To enable them, simply import formulaPlugin
and add it to your plugins via .codedoc/config.ts
:
1linkimport { configuration } from '@codedoc/core';
2linkimport { formulaPlugin } from '@codedoc/core/components';
3link
4link// ...
5link
6linkexport const config = /*#__PURE__*/configuration({
7link // ...
8link plugins: [
9link // ...
10link formulaPlugin
11link ],
12link // ...
13link});
CODEDOC uses KaTeX for producing its formulas, which means you can check this support table to find out which TeX functions are available. If you are lazy like me, you can also just use this nice cheatsheet:
Markdown syntax can collide with Tex functions. For example, if you have this formula:
1link\begin{pmatrix}
2link1 & -1 \\
3link-1 & i
4link\end{pmatrix}
Then the row delimiter, \\
, would collide with markdown syntax.
To avoid that, you can simply enclose the colliding parts
with single backtick (i.e. `
character):
1link> :Formula
2link>
3link> \begin{pmatrix}
4link> 1 & -1 `\\` <!--> the `\\` is enclosed with backticks to avoid collision with markdown -->
5link> -1 & i
6link> \end{pmatrix}
Alternatively, you could put all of your formula in a code-block (enclose it with three backticks, i.e. ```
):
1link> :Formula
2link>
3link> ``` <!--> the whole formula is enclosed-->
4link> \begin{pmatrix}
5link> 1 & -1 \\ <!--> so the \\ doesn't need to be any more-->
6link> -1 & i
7link> \end{pmatrix}
8link> ```
You can use align
property to align formulas at the center. It can either
be set to left
or center
:
1link> :Formula align=center
2link>
3link> G_{\mu\nu} + \Lambda g_{\mu\nu} = \cfrac{8\pi G}{c^4}T_{\mu\nu}
You can also utilize size
property to control size of your formulas. It can either
be set to normal
or large
:
1link> :Formula size=large, align=center
2link>
3link> G_{\mu\nu} + \Lambda g_{\mu\nu} = \cfrac{8\pi G}{c^4}T_{\mu\nu}
Each paragraph or code-block will be assumed as one line of formula, independent of how many actual lines it consists of:
1link> :Formula
2link>
3link> \text{let}`\;`s \equiv G \cancel{\vdash} s
4link>
5link> G \vdash s \implies G \vdash (G \cancel{\vdash} s) \implies \bot
6link>
7link> G \vdash \neg{s} \implies G \vdash (G \vdash s) \implies G \vdash s \implies \bot
8link>
9link> \implies \neg(G \vdash s) \land \neg(G \vdash \neg{s}) `\\` <!--> despite the newline, these will all be displayed as one "line" -->
10link> \implies G `\;`\text{is not complete.} <!--> despite the newline, these will all be displayed as one "line" -->
1link> :Formula
2link>
3link> ```
4link> \frak{L}_{SM} = \quad
5link> \underbrace{
6link> \frac{1}{4} W_{\mu\nu}
7link> \cdot \frac{1}{4} W^{\mu\nu}
8link> - \frac{1}{4} G^a_{\mu\nu} G^{\mu\nu}_a
9link> }_{\tiny{\text{kinetic energies and self-interactions of gauge bosons}}}
10link> ```
11link> ```
12link> \quad\quad\;+ \quad \underbrace{
13link> \bar{L} \gamma^{\mu} (i\partial_\mu - \frac{1}{2}g\tau \cdot W_\mu - \frac{1}{2}g'YB_\mu)L
14link> + \bar{R} \gamma^{\mu} (i\partial_\mu - \frac{1}{2}g'YB_\mu)R
15link> }_{\tiny{\text{kinetic energies and electroweak interactions of fermions}}}
16link> ```
17link> ```
18link> \quad\quad\; + \quad \underbrace{
19link> \frac{1}{2}|(i\partial_\mu - \frac{1}{2}g\tau \cdot W_\mu) - \frac{1}{2}g'YB_\mu|^2 - V(\phi)
20link> }_{\tiny{W\pm,Z,\gamma\text{and Higgs masses and couplings}}}
21link> ```
22link> ```
23link> \quad\quad\; + \quad \underbrace{
24link> g''(\bar{q}\gamma^\mu T_a q) G^a_\mu
25link> }_{\tiny{\text{interactions between gluons and quarks}}} \\ <!--> despite the newline, these will all be displayed as one "line" -->
26link> \space \\ <!--> despite the newline, these will all be displayed as one "line" -->
27link> \quad\quad\; + \quad \underbrace{
28link> (G_1 \bar{L}\phi R + G_2 \bar{L}\phi_c R + h.c.)
29link> }_{\tiny{\text{fermion masses and couplings to Higgs}}}
30link> ```