Skip to content

Commit 346cc46

Browse files
sashmitjevakallio
andauthored
Update math-support.md (foambubble#224)
* Update math-support.md Explains how this mechanism works and adds some ideas on alternatives. * Improve document structure Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
1 parent f63e780 commit 346cc46

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

docs/math-support.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ layout: mathjax
44

55
# Math Support
66

7-
The published pages don't support math formulas by default. To enable this feature, you can add the following code snippet to the end of `_layouts/page.html`:
7+
Published Foam pages don't support math formulas by default. To enable this feature, you can add the following code snippet to the end of `_layouts/page.html`:
88

99
```html
1010
<script src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
@@ -18,11 +18,26 @@ The published pages don't support math formulas by default. To enable this featu
1818
</script>
1919
```
2020

21-
Example of inline math: $e^{i \pi}+1=0$
22-
Example of displayed math:
21+
This approach uses the [MathJax](https://www.mathjax.org/) library to render anything delimited by ```$``` (customizable in the snippet above) pairs to inline math and ```$$``` to blocks of math (like a html div tag) using with the AMS-LaTeX dialect embedded within MathJax.
22+
23+
Example of inline math using `$...$`:
24+
25+
`$e^{i \pi}+1=0$`, becomes $e^{i \pi}+1=0$
26+
27+
Example of a math block using `$$...$$`:
28+
29+
`$$ f_{\mathbf{X}}\left(x_{1}, \ldots, x_{k}\right)=\frac{\exp \left(-\frac{1}{2}(\mathbf{x}-\boldsymbol{\mu})^{\mathrm{T}} \mathbf{\Sigma}^{-1}(\mathbf{x}-\boldsymbol{\mu})\right)}{\sqrt{(2 \pi)^{k}|\mathbf{\Sigma}|}} $$`
30+
31+
Becomes:
2332

2433
$$ f_{\mathbf{X}}\left(x_{1}, \ldots, x_{k}\right)=\frac{\exp \left(-\frac{1}{2}(\mathbf{x}-\boldsymbol{\mu})^{\mathrm{T}} \mathbf{\Sigma}^{-1}(\mathbf{x}-\boldsymbol{\mu})\right)}{\sqrt{(2 \pi)^{k}|\mathbf{\Sigma}|}} $$
2534

35+
## Alternative approaches
36+
37+
There are other dialects of LaTeX (instead of AMS), and other JavaScript rendering libraries you may want to use. In a future version of Foam, we may support KaTeX syntax out of the box, but at this time, these integrations are left as an exercise to the user.
38+
39+
## Why don't my Math expressions work on my Foam's home page?
40+
2641
If you want the index page of your Foam site to render maths, you'll need to add that to `_layouts/home.html` as well, or change the layout of the index page to be "page" instead of "home" by putting this Front Matter on the top of your `readme.md/index.md`:
2742

2843
```
@@ -33,4 +48,4 @@ layout: page
3348
# Your normal title here
3449
```
3550

36-
Reference: [How to support latex in github-pages](https://stackoverflow.com/questions/26275645/how-to-support-latex-in-github-pages)
51+
Reference: [How to support latex in github-pages](https://stackoverflow.com/questions/26275645/how-to-support-latex-in-github-pages)

0 commit comments

Comments
 (0)