From 5ba1b98ab3dd0559d6b841fe9e230557bb019af2 Mon Sep 17 00:00:00 2001 From: Alex Pozhylenkov Date: Mon, 9 Sep 2024 16:02:36 +0300 Subject: [PATCH] feat: Enable LaTex mathematical equations format for MkDocs (#304) * enable latex capabilities * fix spelling * fix spelling --------- Co-authored-by: Stefano Cunego <93382903+kukkok3@users.noreply.github.com> --- docs/src/appendix/examples/latex.md | 28 +++++++++++++++++++++++ earthly/docs/common/javascript/mathjax.js | 21 +++++++++++++++++ earthly/docs/common/std-theme.yml | 4 +++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 docs/src/appendix/examples/latex.md create mode 100644 earthly/docs/common/javascript/mathjax.js diff --git a/docs/src/appendix/examples/latex.md b/docs/src/appendix/examples/latex.md new file mode 100644 index 000000000..c6cb7ac11 --- /dev/null +++ b/docs/src/appendix/examples/latex.md @@ -0,0 +1,28 @@ + + +# 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} diff --git a/earthly/docs/common/javascript/mathjax.js b/earthly/docs/common/javascript/mathjax.js new file mode 100644 index 000000000..adbf17523 --- /dev/null +++ b/earthly/docs/common/javascript/mathjax.js @@ -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() +}) \ No newline at end of file diff --git a/earthly/docs/common/std-theme.yml b/earthly/docs/common/std-theme.yml index 913b0052e..f5e36cb23 100644 --- a/earthly/docs/common/std-theme.yml +++ b/earthly/docs/common/std-theme.yml @@ -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. @@ -118,4 +118,6 @@ extra: extra_javascript: - javascript/massillia-graphviz.js + - javascript/mathjax.js + - https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js \ No newline at end of file