数学公式
数学方程可通过 KaTeX 渲染。
用法
请参阅 KaTeX 文档以了解详情。
行内公式
要书写行内公式,可以把 LaTeX 公式用 $
包裹:
令 $f\colon[a,b]\to\R$ 为一个黎曼可积的函数。 令 $F\colon[a,b]\to\R$ 等于 $F(x)=\int_{a}^{x} f(t)\,dt$。 因此,$F$ 是连续的,并且对于所有使得 $f$ 在 $x$ 处连续的 $x$,$F$ 都在 $x$ 处可微,并且有 $F'(x)=f(x)$.
http://localhost:3000
令 为一个黎曼可积的函数。 令 等于 。 因此, 是连续的,并且对于所有使得 在 处连续的 , 都在 处可微,并且有 .
块级公式
要书写块级公式(也就是显示模式 display mode),要使用 $$
和一个换行:
$$
I = \int_0^{2\pi} \sin(x)\,dx
$$
http://localhost:3000
Enabling math equations
Enable KaTeX:
-
Install the
remark-math
andrehype-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
warningMake sure to use
remark-math 6
andrehype-katex 7
for Docusaurus v3 (using MDX v3). We can't guarantee other versions will work. -
These 2 plugins are only available as ES Modules. We recommended to use an ES Modules config file:
ES module docusaurus.config.jsimport remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
export default {
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
path: 'docs',
remarkPlugins: [remarkMath],
rehypePlugins: [rehypeKatex],
},
},
],
],
};Using a CommonJS config file?
If you decide to use a CommonJS config file, it is possible to load those ES module plugins thanks to dynamic imports and an async config creator function:
CommonJS module docusaurus.config.jsmodule.exports = async function createConfigAsync() {
return {
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
path: 'docs',
remarkPlugins: [(await import('remark-math')).default],
rehypePlugins: [(await import('rehype-katex')).default],
},
},
],
],
};
};