Skip to content

Commit

Permalink
feat: Enable LaTex mathematical equations format for MkDocs (#304)
Browse files Browse the repository at this point in the history
* enable latex capabilities

* fix spelling

* fix spelling

---------

Co-authored-by: Stefano Cunego <93382903+kukkok3@users.noreply.github.com>
  • Loading branch information
Mr-Leshiy and kukkok3 authored Sep 9, 2024
1 parent 94a7ea2 commit 5ba1b98
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
28 changes: 28 additions & 0 deletions docs/src/appendix/examples/latex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!-- cspell: words infty -->

# LaTex formulas

Simple formula as a separate block:
\begin{equation}
5 = 2 + 3
\end{equation}

Simple formula inside the sentence: $5 = 2 + 3$.

More complex examples:

\begin{equation}
e^{ix} = cox(x) + i sin(x)
\end{equation}

\begin{equation}
cos(x) = \frac{e^{ix} + e^{-ix}}{2}
\end{equation}

\begin{equation}
sin(x) = \frac{e^{ix} - e^{-ix}}{2i}
\end{equation}

\begin{equation}
f(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty} (a_n cos(nx) + b_n sin(nx))
\end{equation}
21 changes: 21 additions & 0 deletions earthly/docs/common/javascript/mathjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// cspell: words arithmatex

window.MathJax = {
tex: {
inlineMath: [ ["\\(","\\)"] ],
displayMath: [ ["\\[","\\]"] ],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*",
processHtmlClass: "arithmatex"
}
};

document$.subscribe(() => {
MathJax.startup.output.clearCache()
MathJax.typesetClear()
MathJax.texReset()
MathJax.typesetPromise()
})
4 changes: 3 additions & 1 deletion earthly/docs/common/std-theme.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# cspell: words Diagramsnet, pymdownx, linenums, inlinehilite, superfences,
# cspell: words tasklist, betterem, materialx, twemoji, smartsymbols,
# cspell: words kroki, excalidraw, glightbox, cips, pygments, arithmatex, fontawesome
# cspell: words massillia
# cspell: words massillia, mathjax

site_author: The Project Catalyst Team
copyright: (c) 2023 Input Output Global Ltd.
Expand Down Expand Up @@ -118,4 +118,6 @@ extra:
extra_javascript:
- javascript/massillia-graphviz.js
- javascript/mathjax.js
- https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js

0 comments on commit 5ba1b98

Please sign in to comment.