数学公式
Mathematical equations can be rendered using KaTeX.
Usage
Please read KaTeX documentation for more details.
Inline
Write inline math equations by wrapping LaTeX equations between $
:
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)$.
http://localhost:3000
令 为一个黎曼可积的函数。 令 等于 。 因此, 是连续的,并且对于所有使得 在 处连续的 , 都在 处可微,并且有 .
Blocks
For equation block or display mode, use line breaks and $$
:
$$
I = \int_0^{2\pi} \sin(x)\,dx
$$
http://localhost:3000
Configuration
To enable KaTeX, you need to install remark-math
and rehype-katex
plugins.
- npm
- Yarn
- pnpm
npm install --save remark-math@6 rehype-katex@7
yarn add remark-math@6 rehype-katex@7
pnpm add remark-math@6 rehype-katex@7
warning
Make sure to use remark-math 6
and rehype-katex 7
for Docusaurus v3 (using MDX v3). We can't guarantee other versions will work.
Those 2 plugins are now only available as ES Modules. To simplify usage, it is recommended to use an ES Modules config file:
ES module docusaurus.config.js
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
export default {
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
path: 'docs',
remarkPlugins: [remarkMath],
rehypePlugins: [rehypeKatex],
},
},
],
],
};