0

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:

pdf output of quarto reprex

but I can't get the html version to load the \indist macro from statmath. Instead I get:

html output of quarto reprex

Is there a way to make this work?

asked Aug 18, 2025 at 22:57
0

1 Answer 1

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.

answered Aug 19, 2025 at 19:53
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @davide-cervone! Any chance there's an easy way to define custom macros in a separate file and pull them in all at once? Looks like docs.mathjax.org/en/latest/input/tex/… gets close
You could have an external file define the 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.)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.