Star

MIT License
Copyright © 2020
CONNECT-platform

linkFormula

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> ```

fn={1if n2fn1+fn2otherwisef_n = \begin{cases}1 & \text{if \(n \leq 2\)} \\f_{n - 1} + f_{n - 2} & \text{otherwise} \\\end{cases}1

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 LSM\frak{L}_{SM}, 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.


linkEnabling 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:

.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});


linkTeX Capabilities

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:

TeX Cheatsheet

linkSyntax Collision

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}

(111i)\begin{pmatrix} 1 & -1 \\ -1 & i \end{pmatrix}1

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> ```

(111i)\begin{pmatrix}1 & -1 \\-1 & i\end{pmatrix}1

linkSize and Alignment

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}

Gμν+Λgμν=8πGc4TμνG_{\mu\nu} + \Lambda g_{\mu\nu} = \cfrac{8\pi G}{c^4}T_{\mu\nu}1

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}

Gμν+Λgμν=8πGc4TμνG_{\mu\nu} + \Lambda g_{\mu\nu} = \cfrac{8\pi G}{c^4}T_{\mu\nu}1

linkFormula Lines

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" -->

let  sGs\text{let}\;s \equiv G \cancel{\vdash} s1
Gs    G(Gs)    G \vdash s \implies G \vdash (G \cancel{\vdash} s) \implies \bot2
G¬s    G(Gs)    Gs    G \vdash \neg{s} \implies G \vdash (G \vdash s) \implies G \vdash s \implies \bot3
    ¬(Gs)¬(G¬s)    G  is not complete.\implies \neg(G \vdash s) \land \neg(G \vdash \neg{s}) \\ \implies G \;\text{is not complete.}4

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> ```

LSM=14Wμν14Wμν14GμνaGaμνkinetic energies and self-interactions of gauge bosons\frak{L}_{SM} = \quad\underbrace{ \frac{1}{4} W_{\mu\nu} \cdot \frac{1}{4} W^{\mu\nu} - \frac{1}{4} G^a_{\mu\nu} G^{\mu\nu}_a}_{\tiny{\text{kinetic energies and self-interactions of gauge bosons}}}1
  +Lˉγμ(iμ12gτWμ12gYBμ)L+Rˉγμ(iμ12gYBμ)Rkinetic energies and electroweak interactions of fermions\quad\quad\;+ \quad \underbrace{ \bar{L} \gamma^{\mu} (i\partial_\mu - \frac{1}{2}g\tau \cdot W_\mu - \frac{1}{2}g'YB_\mu)L + \bar{R} \gamma^{\mu} (i\partial_\mu - \frac{1}{2}g'YB_\mu)R}_{\tiny{\text{kinetic energies and electroweak interactions of fermions}}}2
  +12(iμ12gτWμ)12gYBμ2V(ϕ)W±,Z,γand Higgs masses and couplings\quad\quad\; + \quad \underbrace{ \frac{1}{2}|(i\partial_\mu - \frac{1}{2}g\tau \cdot W_\mu) - \frac{1}{2}g'YB_\mu|^2 - V(\phi)}_{\tiny{W\pm,Z,\gamma\text{and Higgs masses and couplings}}}3
  +g(qˉγμTaq)Gμainteractions between gluons and quarks   +(G1LˉϕR+G2LˉϕcR+h.c.)fermion masses and couplings to Higgs\quad\quad\; + \quad \underbrace{ g''(\bar{q}\gamma^\mu T_a q) G^a_\mu}_{\tiny{\text{interactions between gluons and quarks}}} \\\space \\\quad\quad\; + \quad \underbrace{ (G_1 \bar{L}\phi R + G_2 \bar{L}\phi_c R + h.c.)}_{\tiny{\text{fermion masses and couplings to Higgs}}}4
FormulaEnabling FormulasTeX CapabilitiesSyntax CollisionSize and AlignmentFormula Lines

Home Overview CLI Theme

Markdownchevron_right
Code Featureschevron_right

Images & Assets

Configurationchevron_right
Customizationchevron_right