On Sunday, 10 October 2021 11:14:24 CEST Rudolf Adamkovič wrote: > I would like to use the "\mathclap" command from the "mathtools" package in > my Org document. In LaTeX, it works. For HTML, I visited the Org manual [1] > where I saw the following example: > > #+HTML_MATHJAX: cancel.js noErrors.js > > with a comment "it loads the two MathJax extensions ‘cancel.js’ and > ‘noErrors.js’ [132]." (As a side-note, the first link in [132] points to > 404.) Thus, I put the following into my Org file > > #+HTML_MATHJAX: mathtools.js >
With similar scenario I ended up with: (and `mathjax` extensions work very well) ```org-mode #+STARTUP: latexpreview #+BEGIN_EXPORT html <script> window.MathJax = { loader: { paths: {unicodeMath: 'https://cdn.jsdelivr.net/npm/@amermathsoc/mathjax-unicode-math@1/browser'}, load: ['[tex]/mathtools', '[unicodeMath]/unicode-math.js']}, tex: {packages: {'[+]': ['mathtools', 'unicode-math']}}}; </script> #+END_EXPORT \begin{array}{ccc} \underset{\longrightarrow}{\lim}^f(\alpha_1 \circ p_1) &\overset{\underset{\longrightarrow}{\lim}^f \phi}{\longrightarrow}& \underset{\longrightarrow}{\lim}^f(\alpha_2 \circ p_2) \\ {}^{\mathllap{\simeq}}\downarrow && \downarrow^{\mathrlap{\simeq}} \\ \underset{\longrightarrow}{\lim}^f \alpha_1 &\underset{f}{\longrightarrow}& \underset{\longrightarrow}{\lim}^f \alpha_2 \end{array} (diagram above from: [[https://ncatlab.org/nlab/show/ind-object][ind-object in nLab]]) \(\Bbbc\) This above uses the other extension, unicode-math. ``` It works when exporting to `latex` and then `pdf`, it works very well when exporting to `html` via `org-html-export-to-html`, it almost works with `org-latex-preview`. Here the relevant part of my `config.org`: ```org-mode #+begin_src emacs-lisp (with-eval-after-load 'org (add-to-list 'org-latex-packages-alist '("" "stmaryrd" t)) (add-to-list 'org-latex-packages-alist '("" "tikz-cd" t)) (add-to-list 'org-latex-packages-alist '("" "amscd" t)) (add-to-list 'org-latex-packages-alist '("" "mathtools" t)) (add-to-list 'org-latex-packages-alist '("" "unicode-math" t)) ;; (add-to-list 'org-latex-packages-alist '("" "breqn" t)) (add-to-list 'org-latex-packages-alist '("" "thisisastupidtestfile" t)) (setq org-latex-create-formula-image-program 'dvisvgm) (setq org-format-latex-options (plist-put org-format-latex-options :scale 0.80))) #+end_src ``` `thisisastupidtestfile.sty` contains a few straightforward macro of the sort of `\newcommand{\calT}{\mathcal{T}}`. Everything works save `unicode-math` which doesn't work with anything `dvi`. I use `dvisvgm` because it allows `tikz` to work with `org-latex-preview`. Cheers, Chris > but it seems to do nothing; the exported HTML code not even contain the word > "mathtools". > > A file that demonstrates the problem: > > #+LATEX_HEADER: \usepackage{mathtools} > #+HTML_MATHJAX: mathtools.js > > \begin{equation*} > \begin{aligned} > \lim_{R\to0}F_1 > =\lim_{R\to0}\frac{2PR}{P+R} > =\lim_{R\to0}\frac{2\cdot0\cdot{}R}{0+R} > =\lim_{R\to0}\frac{0}{R}, > =\underbrace{\lim_{R\to0}\frac{0}{1}}_{\mathclap{\text{by L'Hôpital's Rule > with $\frac{d}{dR}R=1$}}} > =\lim_{R\to0}0 > =0. > \end{aligned} > \end{equation*} > > Rudy > > [1] https://orgmode.org/manual/Math-formatting-in-HTML-export.html > >