Hey everyone,

At the [last meetup] on [2025-06-11 Wed] we discussed Karthik &
Timothy’s new `LaTeX' preview feature ([repository]). One enhancement
is an adjusted baseline of formulas rendered and embedded as `SVG' in
`HTML' export, which makes it a viable `JavaScript'-free option. I
asked about exporting `MathML' as another option for `HTML', and Ihor
directed me towards the `ODT' export as a starting point.

Before going into details, why might you prefer `MathML' for equations
in `HTML'?

⁃ It “degrades” gracefully compared to `LaTeX' markup:
  ⁃ in the absence of `MathJax', major browsers [support] `MathML'
    (`MathML Core' at least),
  ⁃ `MathJax' [supports] `MathML' and provides [accessibility]
    [extensions] (this made me rethink my stance on `JS').

⁃ It integrates closely with `HTML':
  ⁃ baseline alignment is handled by the browser,
  ⁃ “dark mode” works automatically,
  ⁃ the math font can be matched to the text through `CSS',
  ⁃ math elements can also be styled with `CSS', e.g. colour all
    square roots:

    #+begin_src css
    msqrt { color: red; }
    #+end_src

⁃ That’s what `MathML' was built for ;)

The following is a summary of a few approaches I took and the
challenges I faced. Attached is an `org' file with equations in `TeX'
format gathered from various `MathML' “torture” tests if you want to
try it yourself. Please let me know what you think!

[last meetup] <https://list.orgmode.org/878ql1bt4s.fsf@localhost/>

[repository] <https://code.tecosaur.net/tec/org-mode/>

[support] <https://caniuse.com/mathml>

[supports] <https://docs.mathjax.org/en/latest/input/mathml.html>

[accessibility]
<https://docs.mathjax.org/en/latest/basic/a11y-extensions.html>

[extensions]
<https://docs.mathjax.org/en/latest/options/accessibility.html>


Conversion
══════════

There are several libraries that convert from `TeX' to `MathML', but I
will only mention a few:

1. [LaTeXML]
   ⁃ behind the [DLMF], [ar5iv], and the [experimental HTML] format on
     the `arχiv',
2. [tex4ht],
   ⁃ part of `TeX' distributions,
3. [pandoc].

To produce the best output, these generally want to act on a complete
`TeX' file. However, you might want to have `org' handle the `HTML'
export and limit the converters to math fragments instead:

1. `latexmlmath' is exactly for this, and `latexmlc' can be convinced
   to do the same:

   #+begin_src shell
   latexmlc 'literal:\[\sqrt{1+x^2}\]' --profile=math --presentationmathml
   #+end_src

2. `make4ht' can read from standard input if you wrap it in a minimal
   document, but as far as I can tell it can’t write fragments to
   standard output:

   #+begin_src shell
   make4ht - "mathml" <<< "\documentclass{standalone}
   \begin{document}\[\sqrt{1+x^2}\]\end{document}"
   #+end_src

3. `pandoc' wraps the output in a paragraph, but otherwise works:

   #+begin_src shell
   pandoc -f latex -t html5 --mathml <<< '\[\sqrt{1+x^2}\]' | sed 's/<\/\?p>//g'
   #+end_src

[LaTeXML] <https://math.nist.gov/~BMiller/LaTeXML/>

[DLMF] <https://dlmf.nist.gov/>

[ar5iv] <https://ar5iv.labs.arxiv.org/>

[experimental HTML] <https://info.arxiv.org/about/accessible_HTML.html>

[tex4ht] <https://tug.org/tex4ht/>

[pandoc] <https://pandoc.org/>


Math Fragments
══════════════

When `org-html-with-latex' is `html', the
`org-latex-to-html-convert-command' is invoked on `LaTeX' fragments to
produce `MathML' which is embedded in the `HTML', e.g.

#+begin_src emacs-lisp
(setopt org-html-with-latex 'html
        org-latex-to-html-convert-command
        "latexmlc literal:%i --profile=math --preload=amscd.sty -pmml 
2>/dev/null")
#+end_src

This works really well across all the browsers I’ve tested. Some of
the drawbacks include:

⁃ With `org-html-with-latex' equal to `html' you’re forced to give up
  the `MathJax' script. Since `MathJax' cooperates with `MathML', you
  might still want the script to be embedded (or maybe conditionally
  loaded, as in [LaTeXML-maybeMathjax.js]).

⁃ `AMS' environments like `equation' are not touched by
  `org-latex-to-html-convert-command', in contrast to the
  `org-latex-to-mathml-convert-command' used in `ODT' export:

  #+begin_src emacs-lisp
  (setopt org-latex-to-mathml-convert-command
          "latexmlmath %i --presentationmathml=%o")
  #+end_src

  This leaves the raw `AMS' environments in the `HTML', and by default
  there’s no `MathJax' to smooth things over.

⁃ Conversion has no knowledge of the preamble, and has to be part of
  the command in a `--preload' or a `--preamble'.

⁃ Processing is slow, i.e. a simple formula takes on the order of a
  few seconds for me. You can speed up subsequent builds by using the
  [latexmls plugin], or something like [latexml-runner], but these are
  unofficial scripts that aren’t distributed widely. The `MathML'
  fragments should be cached on the `emacs' side to guard against this
  (see the next approach).

⁃ Since we’re acting on fragments, content markup contains duplicate
  `IDs' which trips up accessibility validation.

[LaTeXML-maybeMathjax.js]
<https://github.com/brucemiller/LaTeXML/blob/master/lib/LaTeXML/resources/javascript/LaTeXML-maybeMathjax.js>

[latexmls plugin] <https://github.com/dginev/LaTeXML-Plugin-latexmls/>

[latexml-runner] <https://github.com/dginev/latexml-runner>


Preview backend
═══════════════

Another way to approach this is to add a `mathml' entry to
`org-preview-latex-process-alist':

#+begin_src emacs-lisp
(setopt org-preview-latex-process-alist
        '((mathml :program ("latexml" "xmllint")
                  :description "LaTeX → MathML"
                  :message "You need to install LaTeXML and XmlLint."
                  :image-input-type "html"
                  :image-output-type "mathml"
                  :latex-compiler
                  ("latexmlc --presentationmathml --log=%f.log --base=%o 
--destination=%O %f")
                  :image-converter
                  ("xmllint --html --xpath '//math' %f > %O")
                  :post-clean (".tex" ".html" ".css" ".log"))))
#+end_src

Then, with the following value of `org-html-with-latex', `.mathml'
files are generated in the `ltximg' folder:

#+begin_src emacs-lisp
(setopt org-html-with-latex 'mathml)
#+end_src

This /almost/ works, but images created this way will be wrapped in an
`<img>' tag when we need to insert the `MathML' file verbatim. As far
as I can tell there’s no official way to change this behaviour, but as
a proof of concept we can advise `org-html--format-image':

#+begin_src emacs-lisp
(defun org-html--embed-image (source _ _)
  "Return contents of the SOURCE with excess whitespace trimmed."
  (string-trim (f-read-text source)))
(advice-add 'org-html--format-image :override 'org-html--embed-image)
#+end_src

Hacks aside, this works even better than the math fragment approach.

⁃ We still don’t have `MathJax'.

⁃ `AMS' environments are converted correctly.

⁃ The preamble is accounted for.

⁃ `MathML' output is cached, so subsequent exports are very fast.

⁃ We’re still acting on fragments, so content markup contains
  duplicate `IDs'.

On the other hand, since the math colour is explicitly set when
generated this way, “dark mode” / inversion is broken.


Use `LaTeX' as an intermediary
══════════════════════════════

Finally, we could use these tools as intended and export `HTML' by
acting on an intermediate `LaTeX' format. This can be done with a
simple derived backend, where the conversion happens in
`org-html-mathml-compile' using the variable
`org-html-mathml-convert-command':

#+begin_src emacs-lisp
(org-export-define-derived-backend 'html-mathml 'latex
  :menu-entry '(?h "Export to HTML+MathML"
                   ((?m "As HTML+MathML file" org-html-mathml-export-to-file)
                    (?n "As HTML+MathML file and open"
                        (lambda (a s v b)
                          (if a (org-html-mathml-export-to-file t s v b)
                            (org-open-file (org-html-mathml-export-to-file nil 
s v b))))))))

(defun org-html-mathml-export-to-file
    (&optional async subtreep visible-only body-only ext-plist)
  "Export current buffer to LaTeX then process through to HTML+MathML.
Return the HTML file’s name."
  (interactive)
  (let ((texfile (org-export-output-file-name ".tex" subtreep)))
    (org-export-to-file 'latex
        texfile async subtreep visible-only body-only ext-plist
        #'org-html-mathml-compile)))

(defun org-html-mathml-compile (texfile)
  "Compile a TeX file to HTML+MathML.

TEXFILE is the name of the file being compiled. Processing is done
through the command specified in `org-html-mathml-convert-command'.
Output is redirected to a \"*Org HTML+MathML Output*\" buffer.

Return HTML file name or raise an error if it couldn’t be produced."
  (let* ((convert-template org-html-mathml-convert-command)
         (log-buffer-name "*Org HTML+MathML Output*")
         (log-buffer (get-buffer-create log-buffer-name))
         (outfile (with-current-buffer log-buffer
                    (erase-buffer)
                    (message "Processing LaTeX file %s..." texfile)
                    (org-compile-file texfile convert-template "html"
                                      (format "See %S for details" 
log-buffer-name)
                                      log-buffer))))
    outfile))
#+end_src

Here are some settings for the three conversion tools I mentioned:

#+begin_src emacs-lisp
(setopt org-html-mathml-convert-command
        '("latexmlc --presentationmathml --destination=%O %f"))
(setopt org-html-mathml-convert-command
        '("make4ht %f \"mathml\""))
(setopt org-html-mathml-convert-command
        '("pandoc -f latex -t html5 --mathml %f > %O"))
#+end_src

In my testing `LaTeXML' output looked the best, followed closely by
`tex4ht' (the `pandoc' output had several artifacts).

Best,

--
Jacob S. Gordon
jacob.as.gor...@gmail.com
Please avoid sending me HTML emails and MS Office documents.
https://useplaintext.email/#etiquette
#+TITLE: ~MathML~ test document
#+HTML_DOCTYPE: html5
#+LATEX_HEADER: \usepackage{amscd}

* ~W3C~ ~MathML~ test suite

The following equations are from the ~TortureTests.Complexity~ section of the [[https://www.w3.org/Math/testsuite/][W3C MathML test suite]].

+ Bernoulli trials: \(P(E) = \binom{n}{k}p^k(1-p)^{n-k}\).

+ Cauchy–Schwarz inequality:
  \[ \left( \sum_{k = 1}^na_kb_k \right)^2 \le \left( \sum_{k = 1}^na_k \right)^2\left( \sum_{k = 1}^nb_k \right)^2. \]

+ Cauchy integral formula:
  \[ f(z)\cdot\text{Ind}_{\gamma}(z) = \frac{1}{2\pi i}\oint\limits_{\gamma} \frac{f(\xi)}{\xi-z}\mathrm{d}\xi. \]

+ Cross product:
  \[ \mathbf{V}_1\times\mathbf{V}_2 =
    \begin{vmatrix}
      \hat{\imath} & \hat{\jmath} & \hat{k} \\
      V_{1x} & V_{1y} & V_{1z} \\
      V_{2x} & V_{2y} & V_{2z}\end{vmatrix}. \]o

+ Vandermonde determinant:
  \[ \begin{vmatrix}
    1 & 1 & \cdots & 1 \\
    v_1 & v_2 & \cdots & v_n \\
    v_1^2 & v_2^2 & \cdots & v_n^2 \\
    \vdots & \vdots & \ddots & \vdots \\
    v_1^{n-1} & v_2^{n-1} & \cdots & v_n^{n-1}
    \end{vmatrix} = \prod_{\substack{1 \le i \le n \\ 1 \le j \le n}}(v_i - v_j). \]

+ Lorenz equations:
  \[ \begin{split}
      \dot{x} &= \sigma(y - x), \\
      \dot{y} &= x(\rho - z) - y, \\
      \dot{z} &= x y -\beta z.
    \end{split} \]

+ Maxwell’s equations:
  \[\left\{ \begin{aligned}
      \nabla\cdot\vec{\mathbf{D}} &= \rho_f, \\
      \nabla\times\vec{\mathbf{E}} + \frac{\partial\vec{\mathbf{B}}}{\partial t} &= \vec{\mathbf{0}}, \\
      \nabla\cdot\vec{\mathbf{B}} &= 0, \\
      \nabla\times\vec{\mathbf{H}} - \frac{\partial\vec{\mathbf{D}}}{\partial t} &= \vec{\mathbf{J}}_f.
    \end{aligned}\right. \]

+ Einstein’s field equations: \(G_{\mu\nu} + \Lambda g_{\mu\nu} = R_{\mu\nu} + \left(\Lambda - \frac{1}{2}R\right)g_{\mu\nu} = \frac{8\pi G}{c^4}T_{\mu\nu}.\)

+ Rogers–Ramanujan continued fraction:
  \[ \frac{1}{(\sqrt{\varphi\sqrt{5}}-\varphi)e^{\frac{2\pi}{5}}} = 1 + \cfrac{e^{-2\pi}}{1 + \cfrac{e^{-4\pi}}{1 + \cfrac{e^{-8\pi}}{1 + \ddots}}} = \frac{e^{-\frac{2\pi}{5}}}{R(e^{-2\pi})}. \]

+ Another Ramanujan identity:
  \[ \sum_{k = 1}^{\infty} = \frac{1}{2^{\lfloor k\cdot\varphi \rfloor}} = \cfrac{1}{2^0 + \cfrac{1}{2^1 + \ddots}}. \]

+ Rogers–Ramanujan identity:
  \[ 1 + \sum_{k = 1}^{\infty} \frac{q^{k^2+k}}{(1-q)(1-q^2)\cdots(1-q^k)} = \prod_{j = 0}^{\infty}\frac{1}{(1-q^{5j+2})(1 - q^{5j+3})},\;\text{for}\;|q| < 1. \]

+ Commutative diagram:
  \[ \begin{array}{ccc}
      H & \longleftarrow & K \\
      \downarrow &  & \uparrow \\
      H & \longrightarrow & K
    \end{array}, \]
  \[ \begin{CD}
        H     @<<< K \\
        @VVV       @AAA \\
        H     @>>> K \end{CD}. \]


* Mozilla ~MathML~ test

The following equations are from the [[https://www-archive.mozilla.org/projects/mathml/demo/texvsmml.xhtml][Mozilla MathML “torture” test suite]], which are mostly from the indicated sections of the ~TeXbook~.
[[https://fred-wang.github.io/MathFonts/mozilla_mathml_test/][Fred Wang]] and [[https://pshihn.github.io/math-ml/examples/torture.html][Preet Shihn]] provide similar pages with the same tests.

+ Chapter 16:
  \[ x^2y^2, \]
  \[ {}_2F_3. \]

+ Chapter 17:
  \[ \frac{x + y^2}{k+1}, \]
  \[ x + y^{\frac{2}{k+1}}, \]
  \[ \frac{a}{b/2}, \]
  \[ a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \cfrac{1}{a_4}}}}, \]
  \[ a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{a_3 + \frac{1}{a_4}}}}, \]
  \[ \binom{n}{k/2}. \]

+ Exercise 17.7:
  \[ \binom{p}{2}x^2y^{p-2} - \frac{1}{\mathstrut 1-x}\frac{1}{\mathstrut 1-x^2}. \]

+ Chapter 17:
  \[ \sum_{\substack{0 \le i \le m \\ 0 < j < n}}P(i,j). \]

+ Chapter 16:
  \[ x^{2y}. \]

+ Exercise 17.8:
  \[ \sum_{i = 1}^p\sum_{j = 1}^q\sum_{k = 1}^ra_{ij}b_{jk}c_{ki}. \]

+ Chapter 17:
  \[ \sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+x}}}}}}}. \]

+ Exercise 17.10:
  \[ \left(\frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2}\right) \bigl|\varphi(x+iy)\bigr|^2 = 0. \]

+ Chapter 16:
  \[ 2^{2^{2^x}}. \]

+ Chapter 18:
  \[ \int_1^x \frac{\mathrm{d}t}{t}, \]
  \[ \int\!\!\!\int_D \mathrm{d}x\,\mathrm{d}y. \]

+ Exercise 18.23:
  \[ f(x) = \begin{cases}
    1/3 &\text{if } 0 \le x \le 1, \\
    2/3 &\text{if } 3 \le x \le 4, \\
    0   &\text{elsewhere},
  \end{cases}. \]

+ Chapter 18:
  \[ \overbrace{x+\cdots+x}^{k\;\text{times}}. \]

+ Exercise 18.40:
  \[ \sum_{p\;\text{prime}}f(p) = \int_{t > 1} f(t)\,\mathrm{d}\pi(t). \]

+ Exercise 18.41:
  \[ \{ \underbrace{\overbrace{\mathstrut a,\ldots,a}^{k\;a\text{'s}},\overbrace{\mathstrut b,\ldots,b}^{l\; b\text{'s}}}_{k+l\;\text{elements}}\}. \]

+ Exercise 18.42:
  \[ \begin{pmatrix}
   \begin{pmatrix}
      a & b \\ c & d
    \end{pmatrix} &
    \begin{pmatrix}
      e & f \\ g & h
    \end{pmatrix} \\
    0 &
    \begin{pmatrix}
      i & j \\ k & l
    \end{pmatrix} \\
  \end{pmatrix}. \]

+ Exercise 18.43:
  \[ \det\left|\,\begin{matrix}
      c_0 & c_1\hfill & c_2\hfill & \ldots & c_n\hfill \\
      c_1 & c_2\hfill & c_3\hfill & \ldots & c_{n+1}\hfill \\
      c_2 & c_3\hfill & c_4\hfill & \ldots & c_{n+2}\hfill \\
      \,\vdots\hfill & \,\vdots\hfill & \,\vdots\hfill && \,\vdots\hfill \\
      c_n & c_{n+1}\hfill & c_{n+2}\hfill & \ldots & c_{2n}\hfill
    \end{matrix}\right| > 0. \]

+ Chapter 16:
  \[ y_{x^2}, \]
  \[ x_{92}^{31415} + \pi, \]
  \[ x_{y_b^a}^{z_c^d}, \]
  \[ y_3^{\prime\prime\prime}. \]

+ Stirling’s approximation:
  \[ \lim_{n \rightarrow \infty}\frac{\sqrt{2\pi n}}{n!}\left(\frac{n}{e}\right)^n = 1. \]

+ Leibniz formula for the determinant:
  \[ \det(A) = \sum_{\sigma \in S_n} \epsilon(\sigma) \prod_{i = 1}^na_{i,\sigma_i}. \]


* ~MathML~ browser test

The following equations are from the [[http://eyeasme.com/Joe/MathML/MathML_browser_test.html][MathML browser test (presentation markup)]].

+ [[http://en.wikipedia.org/wiki/Axiom_of_power_set][Axiom of power set]]:
  \[ \forall A\; \exists P\; \forall B\; [ B \in P \iff \forall C (C \in B \implies C \in A)]. \]

+ [[http://en.wikipedia.org/wiki/Demorgans_law][De Morgan’s law]]:

  + Logic: \(\neg(p \land q) \iff (\neg p) \lor (\neg q),\)

  + Boolean algebra: \(\overline{\cup_{i = 1}^nA_i} = \cap_{i = 1}^n\overline{A_i}.\)

+ [[http://en.wikipedia.org/wiki/Quadratic_equation][Quadratic formula]]:
  \[ x_{\pm} = \frac{-b \pm \sqrt{b^2 - 4 a c}}{2 a}. \]

+ [[http://en.wikipedia.org/wiki/Combination][Binomial coefficient]]:
  \[ C(n,k) = C_n^k = {}_nC_k = \binom{n}{k} = \frac{n!}{k!(n-k)!}. \]

+ [[http://en.wikipedia.org/wiki/Sophomore's_dream][Sophmore’s dream]]:
  \[ \int_0^1 x^x\,\mathrm{d}x = \sum_{n = 1}^{\infty}\frac{(-1)^{n+1}}{n^n}. \]

+ [[http://en.wikipedia.org/wiki/Divergence][Divergence]]: \(\nabla\cdot\vec{v} = \frac{\partial v_{\mathstrut x}}{\partial x} + \frac{\partial v_{\mathstrut y}}{\partial y} + \frac{\partial v_{\mathstrut z}}{\partial z}.\)

+ [[http://en.wikipedia.org/wiki/Complex_number][Complex number]]:
  \[ c = \overbrace{\underbrace{a}_{\text{real}} + \underbrace{i b}_{\text{imaginary}} }^{\text{complex number}}. \]

+ [[http://en.wikipedia.org/wiki/Moore_matrix][Moore matrix]]:
  \[ M = \begin{bmatrix}
      \alpha_1 & \alpha_1^q & \ldots & \alpha_1^{q^{n-1}} \\
      \alpha_2 & \alpha_2^q & \ldots & \alpha_2^{q^{n-1}} \\
      \vdots & \vdots & \ddots & \vdots \\
      \alpha_m & \alpha_m^q & \ldots & \alpha_m^{q^{n-1}} \\
    \end{bmatrix}.
  \]

+ [[http://en.wikipedia.org/wiki/Sphere][Sphere volume]]: The region occupied by a sphere of radius \(R\) in spherical coordinates is \(S = \{0 \le \varphi < 2\pi,\; 0 \le \theta \le \pi,\; 0 \le \rho \le R\},\) so we can calculate the volume to be \(\frac{4}{3}\pi R^3:\)
  \[ \begin{split}
      \text{Volume} &= \iiint_S \rho^2\sin\theta\,\mathrm{d}\rho\,\mathrm{d}\theta\,\mathrm{d}\varphi, \\
                    &= \int_0^{2\pi}\mathrm{d}\varphi \int_0^{\pi}\sin\theta\,\mathrm{d}\theta\int_0^R\rho^2\,\mathrm{d}\rho, \\
                    &= 2\pi [\cos\theta]_{\pi}^0\left[\frac{1}{3}\rho^3\right]_0^R, \\
                    &= \frac{4}{3}\pi R^3.
    \end{split} \]

+ [[http://en.wikipedia.org/wiki/Schwinger-Dyson_equation][Schwinger–Dyson equation]]:
  \[ \left\langle \psi \left\vert \mathcal{T}\left\{\frac{\delta}{\delta\phi}F[\phi] \right\} \right\vert \psi \right\rangle = -i \left\langle \psi \left\vert \mathcal{T}\left\{F[\phi]\frac{\delta}{\delta\phi}S[\phi] \right\} \right| \psi \right\rangle. \]

+ [[http://en.wikipedia.org/wiki/Differentiable_manifold][Tangent vector of differentiable manifold]]:
  \[ \gamma_1 \equiv \gamma_2 \quad\iff\quad \begin{cases}
      \gamma_1(0) = \gamma_2(0) = p,\text{ and} \\
      \frac{\mathrm{d}}{\mathrm{d}t}\phi\circ\gamma_1(t)\rvert_{t = 0} = \frac{\mathrm{d}}{\mathrm{d}t}\phi\circ\gamma_2(t)\rvert_{t = 0}
    \end{cases}.
  \]

+ [[http://en.wikipedia.org/wiki/Cichon's_diagram][Cichoń’s diagram]]:
  \[\begin{array}{ccccccccccc}
    & & \text{cov}(\mathcal{L}) & \rightarrow & \mathrm{non}(\mathcal{K}) & \rightarrow & \mathrm{cof}(\mathcal{K}) & \rightarrow & \mathrm{cof}(\mathcal{L}) & \rightarrow & 2^{\aleph_0} \\
    & & & & \uparrow & & \uparrow & & & & \\
    & & \Bigg\uparrow & & \mathfrak{b} & \rightarrow & \mathfrak{d} & & \Bigg\uparrow & & \\
    & & & & \uparrow & & \uparrow & & & & \\
    \aleph_1 & \rightarrow & \mathrm{add}(\mathcal{L}) & \rightarrow & \mathrm{add}(\mathcal{K}) & \rightarrow & \mathrm{cov}(\mathcal{K}) & \rightarrow & \mathrm{non}(\mathcal{L}) & &
    \end{array}.\]

+ Multiscripts & Greek alphabet:
  \[ \sideset{_{{}_{\alpha}^{\beta}\mathfrak{A}_{\delta}^{\gamma}}^{{}_{\epsilon}^{\zeta}\mathfrak{B}_{\theta}^{\eta}}}{_{{}_{\rho}^{\sigma}\mathfrak{E}_{\upsilon}^{\tau}}^{{_{\nu}^{\xi}\mathfrak{D}_{\pi}^o}}}\prod_{{}_{\phi}^{\chi}\mathfrak{F}_{\omega}^{\psi}}^{{}_{\iota}^{\kappa}\mathfrak{C}_{\mu}^{\lambda}}. \]

+ Nested roots:
  \[ \frac{\sqrt{1 + \sqrt[3]{2 + \sqrt[5]{3 + \sqrt[7]{4 + \sqrt[11]{5 + \sqrt[13]{6 + \sqrt[17]{7 + \sqrt[19]{A}}}}}}}}}{e^{\pi}} = x^{\prime\prime\prime}. \]

+ Display sizes:
  \[ \displaystyle x^2 + y^2,\;\textstyle x^2 + y^2,\;\scriptstyle x^2 + y^2,\;\scriptscriptstyle x^2+y^2. \]


* Miscellaneous

The following equations are all taken from the ~TeXbook~.

+ Chapter 17:
  \[ \frac{a+1}{b}\bigg/\frac{c+1}{d}. \]

+ Exercise 17.13:
  \[ \pi(n) = \sum_{k = 2}^{n}\left\lfloor \frac{\phi(k)}{k-1}\right\rfloor. \]

+ Exercise 17.14:
  \[ \pi(n) = \sum_{m = 2}^n \left\lfloor \left( \sum_{k = 1}^{m-1}\lfloor(m/k)\big/\lceil m/k\rceil\rfloor\right)^{-1} \right\rfloor. \]

+ Exercise 18.2:
  \[ p_1(n) = \lim_{m\rightarrow\infty}\sum_{\nu = 0}^{\infty}\left(1 - \cos^{2m}(\nu!^n\pi/n) \right). \]

+ Exercise 18.5:
  \[ \binom{n}{k} \equiv \binom{\lfloor n/p\rfloor}{\lfloor k/p\rfloor}\binom{n\bmod p}{k\bmod p}\pmod p. \]

+ Exercise 18.10: Let \(H\) be a Hilbert space, \(C\) a closed bounded convex subset of \(H,\) \(T\) a nonexpansive self map of \(C.\)
  Suppose that as \(n\rightarrow\infty,\) \(a_{n,k} \rightarrow 0\) for each \(k,\) and \(\gamma_n = \sum_{k = 0}^{\infty}(a_{n,k+1}-a_{n,k})^+ \rightarrow 0.\)
  Then for each \(x\) in \(C,\) \(A_nx = \sum_{k = 0}^{\infty}a_{n,k}T^kx\) converges weakly to a fixed point of \(T.\)

+ Exercise 18.11:
  \[ \int_0^{\infty} \frac{t - i b}{t^2+b^2}e^{i a t}\;\mathrm{d}t = e^{a b}E_1(a b),\quad a,b > 0. \]

+ Exercise 18.37:
  \[ \prod_{j \ge 0} \left(\sum_{k \ge 0}a_{j k}z^k\right) = \sum_{n \ge 0}z^n\left(\sum_{\substack{k_0,k_1,\ldots \ge 0 \\ k_0 + k_1 + \cdots = n}} a_{0k_0}a_{1k_1}\ldots\right). \]

+ Exercise 18.38:
  \[ \frac{(n_1+n_2+\cdots+n_m)!}{n_1!n_2!\ldots n_m!} = { n_1 + n_2 \choose n_2 } { n_1 + n_2 + n_3 \choose n_3 } \cdots { n_1 + n_2 + \cdots + n_m \choose n_m }. \]

+ Exercise 19.5:
  \[ \prod_{k \ge 0}\frac{1}{1-q^k z} = \sum_{n \ge 0}z^n\Bigg / \prod_{1 \le k \le n}(1 - q^k). \]

+ Exercise 19.13:
  \[\begin{split} \left(\int_{-\infty}^{+\infty}e^{-x^2}\;\mathrm{d}x\right)^2 &= \int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty}e^{-(x^2+y^2)}\;\mathrm{d}x\,\mathrm{d}y, \\
    &= \int_0^{2\pi}\int_0^{\infty}e^{-r^2}r\;\mathrm{d}r\,\mathrm{d}\theta, \\
  &= 2\pi \left[\frac{1}{2}e^{-r^2}\right]_{\infty}^0, \\
  &= \pi. \end{split} \]


* ~AMS~ math environments

These examples are from /The =LaTeX= Companion, 3ed/, Chapter 11.

+ ~equation*~
  \begin{equation*}
  n^2 + m^2 = k^2
  \end{equation*}

+ ~equation~:
  \begin{equation}
  x^2 = y^2 = z^2
  \end{equation}

+ ~equation+split~:
  \begin{equation}
    \begin{split}
      (a + b)^4 &= (a + b)^2(a + b)^2 \\
                &= (a^2 + 2 a b + b^2)(a^2 + 2 a b + b^2) \\
                &= a^4 + 4a^3b + 6a^2b^2 + 4a b^2 + b^4
    \end{split}
  \end{equation}

+ ~align~:
  \begin{align}
  x^2 + y^2 &= z^2 \\ x^3 + y^3 &< z^3
  \end{align}
  \begin{align}
    x^2 + y^2 &= 1 & x^3 + y^3 &= 1 \\
    x &= \sqrt{1-y^2} & x &= \sqrt[3]{1-y^3}
  \end{align}
  \begin{align}
    x &= y & X &= Y & a &= b + c \\
    x + x^{\prime} &= y + y^{\prime} & X + X^{\prime} &= Y + Y^{\prime} & a^{\prime}b &= c^{\prime}b
  \end{align}
  \begin{align}
    A_1 &= N_0(\lambda ; \Omega^{\prime}) - \phi(\lambda ; \Omega^{\prime}) \\
    A_2 &= \phi(\lambda ; \Omega^{\prime})\phi(\lambda ; \Omega) \\
    \intertext{and finally}
    A_3 &= \mathcal{N}(\lambda ; \omega)
  \end{align}

+ ~align*~:
  \begin{align*}
    (a + b)^3 &= (a + b)(a + b)^2 \\
              &= (a + b)(a^2 + 2 a b + b^2) \\
              &= a^3 + 3a^2b + 3a b^2 + b^3
  \end{align*}

+ ~eqnarray~:
  \begin{eqnarray}
  x^2 + y^2 &= z^2 \\ x^3 + y^3 &< z^3
  \end{eqnarray}

+ ~gather~:
  \begin{gather}
    (a + b)^2 = a^2 + 2 a b + b^2 \\
    (a + b) \cdot (a - b) = a^2 - b^2
  \end{gather}

+ ~subequations~:
  \begin{subequations} \label{eq:1}
    \begin{align}
      f &= g \label{eq:1A} \\
      f^{\prime} &= g^{\prime} \label{eq:1B} \\
      \mathcal{L}f &= \mathcal{L}g \label{eq:1C}
    \end{align}
  \end{subequations}

+ ~boxed~:
  \begin{equation}
  \boxed{W_t - F \subseteq V(P_i) \subseteq W_t}
  \end{equation}


* Raw ~MathML~

#+begin_export html
<math xmlns='http://www.w3.org/1998/Math/MathML' alttext='1+x+x^{2}+\cdots+x^{n}=\frac{1-x^{n+1}}{1-x}' display='block'>
  <mrow>
    <mrow>
      <mn>1</mn>
      <mo>+</mo>
      <mi>x</mi>
      <mo>+</mo>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mi mathvariant="normal">⋯</mi>
      <mo>+</mo>
      <msup>
        <mi>x</mi>
        <mi>n</mi>
      </msup>
    </mrow>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mn>1</mn>
        <mo>−</mo>
        <msup>
          <mi>x</mi>
          <mrow>
            <mi>n</mi>
            <mo>+</mo>
            <mn>1</mn>
          </mrow>
        </msup>
      </mrow>
      <mrow>
        <mn>1</mn>
        <mo>−</mo>
        <mi>x</mi>
      </mrow>
    </mfrac>
  </mrow>
</math>
#+end_export

Reply via email to