diff --git a/components/knowledge/KatexFormula.jsx b/components/knowledge/KatexFormula.jsx
new file mode 100644
index 00000000..45ed764a
--- /dev/null
+++ b/components/knowledge/KatexFormula.jsx
@@ -0,0 +1,50 @@
+import katex from "katex";
+
+/*
+ * Split out from KnowledgeLayout.jsx so pages that never render maths don't
+ * pull the katex JS (and its CSS, imported alongside these components) into
+ * their bundle. Only the ~39 knowledge topics that use / import
+ * from this module.
+ */
+
+/**
+ * Centred display formula, rendered with KaTeX.
+ * `children` is a LaTeX string (use a template literal; `\\` starts a new line,
+ * and `\begin{aligned}…\end{aligned}` lays out a multi-step derivation).
+ * `label` is the accessible description read by screen readers.
+ * `caption` optionally annotates the formula beneath it.
+ */
+export function Formula({ children, label, caption }) {
+ const tex = typeof children === "string" ? children : String(children ?? "");
+ const html = katex.renderToString(tex, {
+ displayMode: true,
+ throwOnError: false,
+ strict: false,
+ });
+ return (
+
+
+ {caption && (
+
+ {caption}
+
+ )}
+
+ );
+}
+
+/** Inline maths, rendered with KaTeX. `children` is a LaTeX string. */
+export function TeX({ children, label }) {
+ const tex = typeof children === "string" ? children : String(children ?? "");
+ const html = katex.renderToString(tex, {
+ displayMode: false,
+ throwOnError: false,
+ strict: false,
+ });
+ return ;
+}
diff --git a/components/knowledge/KnowledgeLayout.jsx b/components/knowledge/KnowledgeLayout.jsx
index 8826b750..8bd76e1d 100644
--- a/components/knowledge/KnowledgeLayout.jsx
+++ b/components/knowledge/KnowledgeLayout.jsx
@@ -1,6 +1,5 @@
import Head from "next/head";
import Link from "next/link";
-import katex from "katex";
import SeoHead from "@/components/seo/SeoHead";
import { useI18n } from "@/contexts/I18nContext";
@@ -12,9 +11,10 @@ import { useI18n } from "@/contexts/I18nContext";
* frame — header, provenance strip, table of contents, prose body, refresher,
* footer nav, SEO + JSON-LD — so each topic page only writes its content.
*
- * Companion primitives (KSection, Callout, Formula, Figure, Term, KList) are
- * exported from this module and are designed to sit inside safely
- * (they opt out with `not-prose` where the typography plugin would interfere).
+ * Companion primitives (KSection, Callout, Figure, Term) are exported from
+ * this module and are designed to sit inside safely (they opt out
+ * with `not-prose` where the typography plugin would interfere). Formula/TeX
+ * live in ./KatexFormula.jsx so pages without maths don't bundle katex.
*/
const ACCENT = "#FF3C3C";
@@ -289,48 +289,6 @@ export function Callout({ type = "note", label, children }) {
);
}
-/**
- * Centred display formula, rendered with KaTeX.
- * `children` is a LaTeX string (use a template literal; `\\` starts a new line,
- * and `\begin{aligned}…\end{aligned}` lays out a multi-step derivation).
- * `label` is the accessible description read by screen readers.
- * `caption` optionally annotates the formula beneath it.
- */
-export function Formula({ children, label, caption }) {
- const tex = typeof children === "string" ? children : String(children ?? "");
- const html = katex.renderToString(tex, {
- displayMode: true,
- throwOnError: false,
- strict: false,
- });
- return (
-
-
- {caption && (
-
- {caption}
-
- )}
-
- );
-}
-
-/** Inline maths, rendered with KaTeX. `children` is a LaTeX string. */
-export function TeX({ children, label }) {
- const tex = typeof children === "string" ? children : String(children ?? "");
- const html = katex.renderToString(tex, {
- displayMode: false,
- throwOnError: false,
- strict: false,
- });
- return ;
-}
-
/** Figure wrapper for inline SVG diagrams + caption. */
export function Figure({ children, caption }) {
return (
diff --git a/components/knowledge/content/artificial-intelligence.jsx b/components/knowledge/content/artificial-intelligence.jsx
index 1c9ed64c..802c6e22 100644
--- a/components/knowledge/content/artificial-intelligence.jsx
+++ b/components/knowledge/content/artificial-intelligence.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/artificial-intelligence.
diff --git a/components/knowledge/content/bayesian-statistics.jsx b/components/knowledge/content/bayesian-statistics.jsx
index 7ff12f3c..149cc348 100644
--- a/components/knowledge/content/bayesian-statistics.jsx
+++ b/components/knowledge/content/bayesian-statistics.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/bayesian-statistics.
diff --git a/components/knowledge/content/calculus-optimisation.jsx b/components/knowledge/content/calculus-optimisation.jsx
index 31b03d01..8a7dab8b 100644
--- a/components/knowledge/content/calculus-optimisation.jsx
+++ b/components/knowledge/content/calculus-optimisation.jsx
@@ -1,5 +1,6 @@
import Link from "next/link";
-import { KSection, Callout, Formula, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/calculus-optimisation.
diff --git a/components/knowledge/content/causal-inference.jsx b/components/knowledge/content/causal-inference.jsx
index 510b359c..e2d5ceca 100644
--- a/components/knowledge/content/causal-inference.jsx
+++ b/components/knowledge/content/causal-inference.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/causal-inference.
diff --git a/components/knowledge/content/cluster-cloud-computing.jsx b/components/knowledge/content/cluster-cloud-computing.jsx
index 208ecd76..1bf2d837 100644
--- a/components/knowledge/content/cluster-cloud-computing.jsx
+++ b/components/knowledge/content/cluster-cloud-computing.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/cluster-cloud-computing.
diff --git a/components/knowledge/content/clustering.jsx b/components/knowledge/content/clustering.jsx
index 4d022a75..2b8e8a56 100644
--- a/components/knowledge/content/clustering.jsx
+++ b/components/knowledge/content/clustering.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/clustering.
diff --git a/components/knowledge/content/computational-statistics.jsx b/components/knowledge/content/computational-statistics.jsx
index df4fd450..2638597e 100644
--- a/components/knowledge/content/computational-statistics.jsx
+++ b/components/knowledge/content/computational-statistics.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/computational-statistics.
diff --git a/components/knowledge/content/conformal-prediction.jsx b/components/knowledge/content/conformal-prediction.jsx
index a9b9938c..fcaaa7eb 100644
--- a/components/knowledge/content/conformal-prediction.jsx
+++ b/components/knowledge/content/conformal-prediction.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/conformal-prediction.
diff --git a/components/knowledge/content/deep-learning.jsx b/components/knowledge/content/deep-learning.jsx
index f304c9c9..b55fed0d 100644
--- a/components/knowledge/content/deep-learning.jsx
+++ b/components/knowledge/content/deep-learning.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/deep-learning.
diff --git a/components/knowledge/content/differential-privacy.jsx b/components/knowledge/content/differential-privacy.jsx
index aa0b75c6..a251119d 100644
--- a/components/knowledge/content/differential-privacy.jsx
+++ b/components/knowledge/content/differential-privacy.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/differential-privacy.
diff --git a/components/knowledge/content/ensemble-methods.jsx b/components/knowledge/content/ensemble-methods.jsx
index c0ec53dd..f3375e4f 100644
--- a/components/knowledge/content/ensemble-methods.jsx
+++ b/components/knowledge/content/ensemble-methods.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/ensemble-methods.
diff --git a/components/knowledge/content/extreme-value-theory.jsx b/components/knowledge/content/extreme-value-theory.jsx
index 63f0a48a..a5bff7e6 100644
--- a/components/knowledge/content/extreme-value-theory.jsx
+++ b/components/knowledge/content/extreme-value-theory.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/extreme-value-theory.
diff --git a/components/knowledge/content/feature-engineering.jsx b/components/knowledge/content/feature-engineering.jsx
index 686fbdeb..30e5f027 100644
--- a/components/knowledge/content/feature-engineering.jsx
+++ b/components/knowledge/content/feature-engineering.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/feature-engineering.
diff --git a/components/knowledge/content/gaussian-processes.jsx b/components/knowledge/content/gaussian-processes.jsx
index 097af1ae..a6406ce6 100644
--- a/components/knowledge/content/gaussian-processes.jsx
+++ b/components/knowledge/content/gaussian-processes.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/gaussian-processes.
diff --git a/components/knowledge/content/graph-neural-networks.jsx b/components/knowledge/content/graph-neural-networks.jsx
index e794ca56..78ff05ab 100644
--- a/components/knowledge/content/graph-neural-networks.jsx
+++ b/components/knowledge/content/graph-neural-networks.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/graph-neural-networks.
diff --git a/components/knowledge/content/information-retrieval.jsx b/components/knowledge/content/information-retrieval.jsx
index b51d0c05..a6d8b8e7 100644
--- a/components/knowledge/content/information-retrieval.jsx
+++ b/components/knowledge/content/information-retrieval.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/information-retrieval.
diff --git a/components/knowledge/content/kalman-filter.jsx b/components/knowledge/content/kalman-filter.jsx
index 60bc01f8..ce18bcce 100644
--- a/components/knowledge/content/kalman-filter.jsx
+++ b/components/knowledge/content/kalman-filter.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/kalman-filter.
diff --git a/components/knowledge/content/large-language-models.jsx b/components/knowledge/content/large-language-models.jsx
index b5afc866..8ee5e4f5 100644
--- a/components/knowledge/content/large-language-models.jsx
+++ b/components/knowledge/content/large-language-models.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/large-language-models.
diff --git a/components/knowledge/content/linear-algebra.jsx b/components/knowledge/content/linear-algebra.jsx
index 551cb4dd..2f65af01 100644
--- a/components/knowledge/content/linear-algebra.jsx
+++ b/components/knowledge/content/linear-algebra.jsx
@@ -1,5 +1,6 @@
import Link from "next/link";
-import { KSection, Callout, Formula, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/linear-algebra.
diff --git a/components/knowledge/content/linear-statistical-models.jsx b/components/knowledge/content/linear-statistical-models.jsx
index e7c12eb4..40787971 100644
--- a/components/knowledge/content/linear-statistical-models.jsx
+++ b/components/knowledge/content/linear-statistical-models.jsx
@@ -1,5 +1,6 @@
import Link from "next/link";
-import { KSection, Callout, Formula, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/linear-statistical-models.
diff --git a/components/knowledge/content/model-evaluation.jsx b/components/knowledge/content/model-evaluation.jsx
index cb9c6a93..1efa1316 100644
--- a/components/knowledge/content/model-evaluation.jsx
+++ b/components/knowledge/content/model-evaluation.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/model-evaluation.
diff --git a/components/knowledge/content/natural-language-processing.jsx b/components/knowledge/content/natural-language-processing.jsx
index 88cd79c3..afb58ee0 100644
--- a/components/knowledge/content/natural-language-processing.jsx
+++ b/components/knowledge/content/natural-language-processing.jsx
@@ -1,4 +1,5 @@
-import { KSection, Callout, Formula, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/natural-language-processing.
diff --git a/components/knowledge/content/network-graph-analysis.jsx b/components/knowledge/content/network-graph-analysis.jsx
index b50cacd7..3b172e22 100644
--- a/components/knowledge/content/network-graph-analysis.jsx
+++ b/components/knowledge/content/network-graph-analysis.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/network-graph-analysis.
diff --git a/components/knowledge/content/operations-research.jsx b/components/knowledge/content/operations-research.jsx
index dd3f8b8f..a97006ae 100644
--- a/components/knowledge/content/operations-research.jsx
+++ b/components/knowledge/content/operations-research.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/operations-research.
diff --git a/components/knowledge/content/pca-dimensionality-reduction.jsx b/components/knowledge/content/pca-dimensionality-reduction.jsx
index 88f6d3ab..a8ab8b59 100644
--- a/components/knowledge/content/pca-dimensionality-reduction.jsx
+++ b/components/knowledge/content/pca-dimensionality-reduction.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/pca-dimensionality-reduction.
diff --git a/components/knowledge/content/probabilistic-graphical-models.jsx b/components/knowledge/content/probabilistic-graphical-models.jsx
index 0f9989cb..29ae9f8b 100644
--- a/components/knowledge/content/probabilistic-graphical-models.jsx
+++ b/components/knowledge/content/probabilistic-graphical-models.jsx
@@ -1,12 +1,6 @@
import Link from "next/link";
-import {
- KSection,
- Callout,
- Formula,
- Figure,
- TeX,
- Term,
-} from "@/components/knowledge/KnowledgeLayout";
+import { KSection, Callout, Figure, Term } from "@/components/knowledge/KnowledgeLayout";
+import { Formula, TeX } from "@/components/knowledge/KatexFormula";
/**
* Per-locale content for /knowledge/probabilistic-graphical-models.
@@ -26,18 +20,60 @@ function BayesNetFigure({ caption, ariaLabel, rainLabel, sprinklerLabel, grassLa
aria-label={ariaLabel}
>
- {rainLabel}
+
+ {rainLabel}
+
- {sprinklerLabel}
-
- {grassLabel}
- {wetLabel}
+
+ {sprinklerLabel}
+
+
+
+ {grassLabel}
+
+
+ {wetLabel}
+
{/* edges */}
-
-
-
+
+
+
-
+
+
+
@@ -244,33 +280,39 @@ function ZhBody() {
return (
<>