| 1 | --- |
| 2 | name: latex |
| 3 | description: Render mathematical equations using KaTeX |
| 4 | --- |
| 5 | |
| 6 | # LaTeX |
| 7 | |
| 8 | Render mathematical equations. Powered by KaTeX. |
| 9 | |
| 10 | ## Inline Math |
| 11 | |
| 12 | ```md |
| 13 | $\sqrt{3x-1}+(1+x)^2$ |
| 14 | ``` |
| 15 | |
| 16 | ## Block Math |
| 17 | |
| 18 | ```md |
| 19 | $$ |
| 20 | \begin{aligned} |
| 21 | \nabla \cdot \vec{E} &= \frac{\rho}{\varepsilon_0} \\ |
| 22 | \nabla \cdot \vec{B} &= 0 |
| 23 | \end{aligned} |
| 24 | $$ |
| 25 | ``` |
| 26 | |
| 27 | ## Line Highlighting |
| 28 | |
| 29 | ```md |
| 30 | $$ {1|3|all} |
| 31 | \begin{aligned} |
| 32 | \nabla \cdot \vec{E} &= \frac{\rho}{\varepsilon_0} \\ |
| 33 | \nabla \cdot \vec{B} &= 0 \\ |
| 34 | \nabla \times \vec{E} &= -\frac{\partial\vec{B}}{\partial t} |
| 35 | \end{aligned} |
| 36 | $$ |
| 37 | ``` |
| 38 | |
| 39 | ## Chemical Equations |
| 40 | |
| 41 | Enable mhchem extension in `vite.config.ts`: |
| 42 | |
| 43 | ```ts |
| 44 | import 'katex/contrib/mhchem' |
| 45 | |
| 46 | export default {} |
| 47 | ``` |
| 48 | |
| 49 | Then use: |
| 50 | |
| 51 | ```md |
| 52 | $$ |
| 53 | \ce{B(OH)3 + H2O <--> B(OH)4^- + H+} |
| 54 | $$ |
| 55 | ``` |
| 56 |