I’m trying to use org-mode to export something as an HTML document, with MathJax equations. I know that MathJax supports the physics package, so it seems like it should be possible to tell emacs to tell MathJax to load physics. But how?

The code suggested in the link above is

window.MathJax = {
  loader: {load: ['[tex]/physics']},
  tex: {packages: {'[+]': ['physics']}}

so I tried putting variations of these lines in the document:

  • #+HTML_MATHJAX: loader: {load: ['[tex]/physics']} tex: {packages: {'[+]': ['physics']}}
  • #+HTML_MATHJAX: load: ['[tex]/physics'] packages: {'[+]': ['physics']}

But neither worked. What’s the right way to do this?


#+TITLE: Some physics
^^^ What can I put here to use the physics package?


Edit: I put one solution down below that uses pandoc.

  • Try simply export via pandoc to html5. No other settings. See supported symbols here: docs.mathjax.org/en/latest/input/tex/macros/index.html
    – Ian
    Commented May 20, 2021 at 13:05
  • Oh, I didn’t consider pandoc! That’s also worth trying. But still, when I run pandoc on this example file (via the shell, not through org-mode) I get errors, I think because pandoc also doesn’t know I need the physics package. I’ll update the question to be more specific.
    – wobtax
    Commented May 20, 2021 at 13:32
  • I suggested html5 - not simply html. Take into account there is a package ox-pandoc which can be added to your configuration and export from emacs. I use doom-emacs configured with (org +pandoc) but I am not pushing you to that (but useful if you need a fast solution).
    – Ian
    Commented May 20, 2021 at 14:25
  • Okay, thanks, I’ve installed ox-pandoc. What should I do to make emacs use it?
    – wobtax
    Commented May 20, 2021 at 15:06
  • Please do not evolve a question by implementing comment suggestions and then saying, in effect, "I tried that and ran into this other problem: XYZ." The question should now be deleted/closed or edited to remove the additional questions.
    – Drew
    Commented May 20, 2021 at 15:10

2 Answers 2


I've probably looked through every single piece of documentation related to Org Mode's LaTeX to HTML export and MathJax, and this is what I've got:

Launch Emacs, then open up your MathJax configuration using M-x org-customize. Go to Org Export -> Org Export HTML -> Org HTML MathJax template. There, you will find a window where you can edit the MathJax config.

Change it up so it looks like this:

<script type="text/x-mathjax-config">
    displayAlign: "%ALIGN",
    displayIndent: "%INDENT",

    extensions: ["[Contrib]/physics/physics.js"],

    "HTML-CSS": { scale: %SCALE,
                    linebreaks: { automatic: "%LINEBREAKS" },
                    webFont: "%FONT"
    SVG: {scale: %SCALE,
          linebreaks: { automatic: "%LINEBREAKS" },
          font: "%FONT"},
    NativeMML: {scale: %SCALE},
    TeX: { equationNumbers: {autoNumber: "%AUTONUMBER"},
           MultLineWidth: "%MULTLINEWIDTH",
           TagSide: "%TAGSIDE",
           TagIndent: "%TAGINDENT"}
<script type="text/javascript"

The important line to add is:

extensions: ["[Contrib]/physics/physics.js"],

When you're in this editing mode the <return> key might not add a whitespace character. Remember that you can always add one using the C-o shortcut. After you're done select [ Apply and save ]. Now the physics package should be working properly.

  • Thanks! This is exactly what I was looking for.
    – wobtax
    Commented Jun 22, 2021 at 11:50

Okay, this works for my specific case (thanks to Ian’s comment):

  1. Install the package ox-pandoc.
  2. Customize the option org-pandoc-options-for-html5 to include mathjax set to t.
  3. Run the command org-pandoc-export-to-html5.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.