Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathJax extensions can't be enabled #1542

Closed
SV-97 opened this issue Aug 8, 2023 · 2 comments · Fixed by #1544
Closed

MathJax extensions can't be enabled #1542

SV-97 opened this issue Aug 8, 2023 · 2 comments · Fixed by #1544

Comments

@SV-97
Copy link

SV-97 commented Aug 8, 2023

Description

I wanted to enable a mathjax extension (ams) due to running into a problem with unknown commands (\substack and \mathclap) however this currently seems to be impossible. In particular the runtime import mechanism provided by MathJax in the form of \require does not work. (I also tried LaTeX's default \usepackage which usually works with mathjax and ran into the same problems).

Reproducing the error

Linear program: {
  formula: |latex
    \\min_{ \\mathclap{\\substack{ x \\in \\mathbb{R}^n \\ x \geq 0 \\ Ax \leq b }}} c^T x
  |
}

yields Undefined control sequence \substack.

Linear program: {
  formula: |latex
    \\require(ams)
    \\min_{ \\mathclap{\\substack{ x \\in \\mathbb{R}^n \\ x \geq 0 \\ Ax \leq b }}} c^T x
  |
}

yields Undefined control sequence \require.

@alixander
Copy link
Collaborator

In particular the runtime import mechanism provided by MathJax in the form of \require does not work.

Right, D2 packages Mathjax at compile-time, so the extensions cannot be dynamically imported.

I'll make a note of this in the docs. In the meantime, ASM looks useful, I included it and used your equation as a test: #1544

@SV-97

@SV-97
Copy link
Author

SV-97 commented Aug 9, 2023

Thanks for the quick fix! I just noticed that my example was a bit off as the \\s inside the substack should've really been \\\\s so that it renders something like this:

substack_example

Although I guess the other variant also works as a basic test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants