NW' Blog
August 15, 2026 · Content Page

Formula Rendering Example (KaTeX)

The blog has the KaTeX formula rendering engine enabled globally: both article bodies and the comment section support writing LaTeX math with $...$ (inline formulas) and $$...$$ (block formulas), with no extra configuration needed.


1. Inline Formulas

Inline formulas are wrapped in single dollar signs: Einstein's mass–energy equation $E = mc^2$ describes the equivalence of mass and energy; the Pythagorean theorem $a^2 + b^2 = c^2$ is a foundation of plane geometry; Euler's identity $e{i\pi} + 1 = 0$ is celebrated as the most beautiful formula in mathematics; and Newton's second law $F = ma$ is the core of classical mechanics.

Inline formulas can nest superscripts, subscripts, and radicals: $e{i\theta} = \cos\theta + i\sin\theta$, $\sqrt{a^2 + b^2}$, $x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.

markdown
Inline formula: $...$ (one dollar sign on each side, must not span lines)

$E = mc^2$
$a^2 + b^2 = c^2$
$e{i\pi} + 1 = 0$
$F = ma$
$e{i\theta} = \cos\theta + i\sin\theta$
$\sqrt{a^2 + b^2}$
$x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$

2. Block Formulas (Clapp frequency formula)

Frequency formula (Clapp):

$$f = \frac{1}{2\pi\sqrt{L_1 \cdot \left( C_{eq} + C_{V1} + C_{par} \right)}}, \qquad \frac{1}{C_{eq}} = \frac{1}{C_1} + \frac{1}{C_2} + \frac{1}{C_3}$$

Substituting the values:

$$\frac{1}{C_{eq}} = \frac{1}{120} + \frac{1}{120} + \frac{1}{18} = 0.0722\ \mathrm{pF^{-1}} \Rightarrow C_{eq} = 13.85\ \mathrm{pF}$$

After substituting L₁, the oscillation frequency can be obtained:

$$f = \frac{1}{2\pi\sqrt{22 \times 10^{-9} \cdot \left( 13.85 + C_{V1} + C_{par} \right) \times 10^{-12}}} \approx 270.8\ \mathrm{MHz}$$

markdown
Block formula: $$...$$ (two dollar signs on each side, may span lines)

$$f = \frac{1}{2\pi\sqrt{L_1 \cdot \left( C_{eq} + C_{V1} + C_{par} \right)}}, \qquad \frac{1}{C_{eq}} = \frac{1}{C_1} + \frac{1}{C_2} + \frac{1}{C_3}$$

$$\frac{1}{C_{eq}} = \frac{1}{120} + \frac{1}{120} + \frac{1}{18} = 0.0722\ \mathrm{pF^{-1}} \Rightarrow C_{eq} = 13.85\ \mathrm{pF}$$

$$f = \frac{1}{2\pi\sqrt{22 \times 10^{-9} \cdot \left( 13.85 + C_{V1} + C_{par} \right) \times 10^{-12}}} \approx 270.8\ \mathrm{MHz}$$

3. Multi-line Formulas

Use the aligned environment to align multi-line formulas (the alignment marker & is written as & in the page source):

$$\begin{aligned} x + y &= 10 \\ 2x - y &= 4 \end{aligned}$$

Use the cases environment to write piecewise functions:

$$f(x) = \begin{cases} x^2, & x \geq 0 \\ -x, & x < 0 \end{cases}$$

A derivation aligned across line breaks:

$$\begin{aligned} S_n &= \sum_{k=1}^{n} k \\ &= \frac{n(n+1)}{2} \end{aligned}$$

markdown
aligned environment (& is the alignment marker, use \\ for line breaks):

$$\begin{aligned} x + y &= 10 \\ 2x - y &= 4 \end{aligned}$$

cases environment (piecewise function):

$$f(x) = \begin{cases} x^2, & x \geq 0 \\ -x, & x < 0 \end{cases}$$

Derivation aligned across line breaks:

$$\begin{aligned} S_n &= \sum_{k=1}^{n} k \\ &= \frac{n(n+1)}{2} \end{aligned}$$

4. Matrices

Matrices use the pmatrix / bmatrix environments:

$$\begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix} \cdot \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} = \begin{pmatrix} b_1 \\ b_2 \end{pmatrix}$$

Determinant:

$$\det(A) = \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc$$

markdown
Matrix environments: pmatrix / bmatrix / vmatrix (& separates columns, \\ for line breaks)

$$\begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix} \cdot \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} = \begin{pmatrix} b_1 \\ b_2 \end{pmatrix}$$

$$\det(A) = \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc$$

5. Calculus

Summation (Basel problem):

$$\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}$$

Integral (Gaussian integral):

$$\int_0^\infty e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2}$$

Limits:

$$\lim_{x \to 0} \frac{\sin x}{x} = 1, \qquad \lim_{x \to \infty} \left( 1 + \frac{1}{x} \right)^x = e$$

Differentiation:

$$\frac{d}{dx} \left( e^{kx} \right) = k e^{kx}, \qquad \frac{\partial^2 u}{\partial x^2} = \frac{1}{c^2} \frac{\partial^2 u}{\partial t^2}$$

markdown
Summation (Basel problem):

$$\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}$$

Integral (Gaussian integral):

$$\int_0^\infty e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2}$$

Limits:

$$\lim_{x \to 0} \frac{\sin x}{x} = 1, \qquad \lim_{x \to \infty} \left( 1 + \frac{1}{x} \right)^x = e$$

Differentiation:

$$\frac{d}{dx} \left( e^{kx} \right) = k e^{kx}, \qquad \frac{\partial^2 u}{\partial x^2} = \frac{1}{c^2} \frac{\partial^2 u}{\partial t^2}$$

6. Symbols and Greek Letters

Common Greek letters:

$$\alpha \quad \beta \quad \gamma \quad \delta \quad \varepsilon \quad \theta \quad \lambda \quad \mu \quad \pi \quad \rho \quad \sigma \quad \phi \quad \omega \quad \Omega$$

Relational symbols: $\leq$ $\geq$ $\approx$ $\neq$ $\equiv$ $\propto$ $\in$ $\notin$ $\subset$ $\cup$ $\cap$ $\forall$ $\exists$ $\infty$ $\pm$ $\times$ $\cdot$ $\rightarrow$

Combinations and vectors: $\binom{n}{k}$, $\vec{F} = m\vec{a}$, $\hat{x}$, $\bar{x}$, $\dot{q}$, $\nabla \times \vec{B} = \mu_0 \vec{J}$

markdown
Greek letters (block):

$$\alpha \quad \beta \quad \gamma \quad \delta \quad \varepsilon \quad \theta \quad \lambda \quad \mu \quad \pi \quad \rho \quad \sigma \quad \phi \quad \omega \quad \Omega$$

Relational symbols (inline):

$\leq$ $\geq$ $\approx$ $\neq$ $\equiv$ $\propto$ $\in$ $\notin$ $\subset$ $\cup$ $\cap$ $\forall$ $\exists$ $\infty$ $\pm$ $\times$ $\cdot$ $\rightarrow$

Combinations and vectors (inline):

$\binom{n}{k}$, $\vec{F} = m\vec{a}$, $\hat{x}$, $\bar{x}$, $\dot{q}$, $\nabla \times \vec{B} = \mu_0 \vec{J}$

7. Formulas Inside Code Blocks Are Not Rendered

To prevent accidental rendering, $$...$$ inside code blocks (pre/code) is displayed as-is, used only to show the syntax source:

markdown
Frequency formula (Clapp):

$$f = \frac{1}{2\pi\sqrt{L_1 \cdot \left( C_{eq} + C_{V1} + C_{par} \right)}}$$

Substituting the values:

$$\frac{1}{C_{eq}} = \frac{1}{120} + \frac{1}{120} + \frac{1}{18} = 0.0722\ \mathrm{pF^{-1}} \Rightarrow C_{eq} = 13.85\ \mathrm{pF}$$

8. Formula Support in the Comment Section

The comment section supports formula rendering too: just write $E = mc^2$ or $$...$$ directly when posting a comment; both the preview and the published comment will be rendered. Try posting a comment containing a formula in the comment section below, for example:

$$R_{th} = \frac{T_j - T_a}{P} \qquad \text{(thermal resistance formula example)}$$

markdown
Comment syntax is exactly the same as the article body (rendered automatically after posting):

$$R_{th} = \frac{T_j - T_a}{P} \qquad \text{(thermal resistance formula example)}$$

Inline formula: $E = mc^2$

\[\int_a^b f(x)\,dx\] (the \[\] block syntax is also supported)

9. Maintenance Notes (When Hand-writing .astro)

When hand-writing formulas in .astro page source, you must pay attention to the following escaping rules. If you use the tool editor (/tool-editor-article/) to import/export, all escaping is handled automatically and no manual changes are needed:

  1. Curly braces { } must be written as &#123; / &#125;: the Astro compiler treats { as the start of an expression, and an unescaped one causes a build-time Syntax error; after the browser parses the DOM it is restored to { and KaTeX scans and renders it normally.
  2. The alignment marker & must be written as &amp;: in the aligned / cases / matrix environments, & is the entity start character in HTML, and writing it bare breaks tag parsing.
  3. A bare < must be written as &lt;: e.g. x < 0; otherwise it is treated as the start of a tag and triggers an Astro parsing error.
  4. Recommended workflow: paste LaTeX into the tool editor for a live preview → export .astro (escaped automatically) → deploy. When hand-writing pages, refer to the code comments on this page.
markdown
✗ Wrong: paste LaTeX directly with { } unescaped → build fails with a Syntax error

$$f = \frac{1}{2\pi\sqrt{L_1 \cdot \left( C_{eq} + C_{V1} + C_{par} \right)}}$$

✓ Correct: curly braces escaped as entities (restored automatically when the browser parses them; KaTeX renders normally)

$$f = \frac&#123;1&#125;&#123;2\pi\sqrt&#123;L_1 \cdot \left( C_&#123;eq&#125; + C_&#123;V1&#125; + C_&#123;par&#125; \right)&#125;&#125;$$

✓ Alignment marker & written as &amp;, less-than sign < written as &lt;:

$$\begin&#123;cases&#125; x^2, &amp; x \geq 0 \\ -x, &amp; x &lt; 0 \end&#123;cases&#125;$$
Comments Leave your thoughts
Guide