I'm trying to use the statmath CTAN package (https://ctan.org/pkg/statmath?lang=en) in Quarto (following https://github.com/quarto-dev/quarto-cli/discussions/1620#discussioncomment-3296389); here's a reprex:
---
title: "Quarto Math"
format:
pdf:
pdf-engine: xelatex
include-in-header:
text: |
\usepackage{statmath}
html:
html-math-method: mathjax
include-in-header:
- text: |
<script>
window.MathJax = {
loader: {
load: ['[tex]/statmath']
},
tex: {
packages: {'[+]': ['statmath']}
}
};
</script>
---
$$X_n \indist X$$
The pdf output works:
but I can't get the html version to load the \indist macro from statmath. Instead I get:
Is there a way to make this work?
1 Answer 1
MathJax is a javascript library that can process a subset of LaTeX commands, but it is not TeX itself, and can't load arbitrary LaTeX packages, only ones that have been reimplemented in javascript. The statmath package is not one of them.
On the other hand, the definition for \indist in statmath is
\newcommand{\indist}{\overset{d}{\to}}
so you can define that yourself before using it. If you want to include that automatically in your MathJax configuration, you can incorporate
window.MathJax = {
tex: {
macros: {
indist: '\\overset{d}{\\to}',
}
}
}
into your MathJax configuration.
2 Comments
defs variable (rather than getting it from a script tag already in the DOM) and use that to define the macros like in the second example in the section you link to. Then load the external script file first. Or you could even have MathJax load the external file using the loader.load array to do it. (Sorry for the long delay in getting back to you.)