Can't render math with Docusaurus

125 views Asked by At

I can't get math equations getting rendered by using KaTex in my markdown files and don't know why. Can anyone help me, please?

I tried to reproduce it by creating a new clean Docusaurus project and afterwards followed the exact instructions on how to include KaTex math.

In this clean project I created an example page under ./src/pages/markdown-math-page.mdx.

---
title: Markdown page example
---

# Markdown page math example

Test math:
$a
$a + b = c$

It renders as shown in the image below, but the math equations aren't rendered as they should. What step am I missing?

Screenshot of the rendered markdown-math-page.mdx page

I tried to reproduce the problem by following all outlined steps in the tutorial. Also there are no error or warning messages once I compile the page. The math just doesn't get rendered as it should.

1

There are 1 answers

0
johann On

To enable KaTex, you need to follow the instructions under the Configuration section: how to configure KaTex math

  1. Install the necessary packages using either npm, yarn, or pnpm
  2. Modify docusaurus.config.js file (import plugins, add them to preset options, and include KaTex stylesheet)

Result:

---
title: Markdown page example
---

# Markdown page math example

Test math:

Let $f\colon[a,b]\to\R$ be Riemann integrable. Let $F\colon[a,b]\to\R$ be
$F(x)=\int_{a}^{x} f(t)\,dt$. Then $F$ is continuous, and at all $x$ such that
$f$ is continuous at $x$, $F$ is differentiable at $x$ with $F'(x)=f(x)$.

enter image description here