Skip to content

Commit b1121d7

Browse files
committed
docs: Document configuration of the remark-math plugin
1 parent d33004d commit b1121d7

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

website/docs/guides/markdown-features/markdown-features-math-equations.mdx

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ Enable KaTeX:
7575
import rehypeKatex from 'rehype-katex';
7676
// highlight-end
7777

78-
// highlight-start
7978
export default {
8079
presets: [
8180
[
@@ -188,6 +187,52 @@ export default {
188187

189188
</details>
190189

190+
## Using double dollar signs as delimiters
191+
192+
In some cases (e.g. prose that includes prices in dollars), it may be undesirable to treat any pair of single dollar signs occurring in the same line as delimiters of math syntax. To configure the plugin to only recognize double dollar signs as delimiters of inline math, set the option set the [`singleDollarTextMath` configuration option]() to `false`:
193+
194+
```js title="docusaurus.config.js"
195+
export default {
196+
presets: [
197+
[
198+
'@docusaurus/preset-classic',
199+
{
200+
docs: {
201+
path: 'docs',
202+
// highlight-start
203+
remarkPlugins: [[remarkMath, {singleDollarTextMath: false}]],
204+
// highlight-end
205+
rehypePlugins: [rehypeKatex],
206+
},
207+
},
208+
],
209+
],
210+
};
211+
```
212+
213+
This will allow writing markdown like:
214+
215+
```latex
216+
The item costs $300 but is available at a discounted rate of $290.
217+
The absolute difference is $$\$300 - \$290 = \$10$$, and the relative difference, as a percentage, is given by:
218+
219+
$$$
220+
\left(1 - \frac{290}{300} \right) \times 100 \approx 3.33 \%
221+
$$$
222+
```
223+
224+
with the results being:
225+
226+
<BrowserWindow>
227+
228+
The item costs \$300 but is available at a discounted rate of \$290. The absolute difference is $$\$300 - \$290 = \$10$$, and the relative difference, as a percentage, is given by:
229+
230+
$$
231+
\left(1 - \frac{290}{300} \right) \times 100 \approx 3.33 \%
232+
$$
233+
234+
</BrowserWindow>
235+
191236
## Self-hosting KaTeX assets {#self-hosting-katex-assets}
192237

193238
Loading stylesheets, fonts, and JavaScript libraries from CDN sources is a good practice for popular libraries and assets, since it reduces the amount of assets you have to host. In case you prefer to self-host the `katex.min.css` (along with required KaTeX fonts), you can download the latest version from [KaTeX GitHub releases](https://github.com/KaTeX/KaTeX/releases), extract and copy `katex.min.css` and `fonts` directory (only `.woff2` font types should be enough) to your site's `static` directory, and in `docusaurus.config.js`, replace the stylesheet's `href` from the CDN URL to your local path (say, `/katex/katex.min.css`).

0 commit comments

Comments
 (0)