question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline equations $...$ do not render with mathjax3

See original GitHub issue

Description

I managed to use mkdocs&mkdocs-material for documentation. When trying to insert some chemical equations , I used to document with pymdownx.arithmatex and the default mathjax2.7 js. It was great and worked well as expected.

However, to render equations with TeX packages like mhchem, chemfig, I would add an extra js for mathjax, and there are only mathjax3 instructions available. Therefore, in my mkdocs.yaml file,

    - 'javascripts\mathjax.js'
    - 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
#    - 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js'
#   - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'

After that, the problem occurs. The euqation donot render correctly.

Expected behavior

Inline equations $\ce{CH2CH=CH2CH3 + CH3CH=CHCH3 ->[Cat] CH2=CHCH3 + CH3CH=CHCH2CH3}$ Block equations $$ \ce{CH2CH=CH2CH3 + CH3CH=CHCH3 ->[Cat] CH2=CHCH3 + CH3CH=CHCH2CH3} $$ both identified and rendered

  • \ce is the macro added for chemical writing.

Actual behavior

Only Block equations rendered, and leave inline equations without $ \ce{CH2CH=CH2CH3 + CH3CH=CHCH3 ->[Cat] CH2=CHCH3 + CH3CH=CHCH2CH3}

Steps to reproduce the bug

  1. With mathjax3 js, My inline equations would not render, just leave $\Delta$ as \Delta, while block equations with chem features render correctly.

  2. mathjax3 js Tried different js, ‘https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js’ and ‘https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js’. Just as Step 1.

  3. With mathjax2.7 js, My inline equations render correctly, content with chem features unable to render.

  4. I notice that the ?config=TeX-MML-AM_CHTML is the difference between original pymdownx.arithmatex instruction. Without the config, mathjax2.7 would not render inline equations . However, mathjax3 do not support such config.

Package versions

  • Python: 3.8.0
  • MkDocs: 1.1
  • Material: 4.6.3.

Project configuration

Follow the instruction on mathjax website and change the 2.7 config to 3.0 with officail tool

mathjax.js content

window.MathJax = {
    TeX: {
      inlineMath: [['$', '$'], ['\\(', '\\)']],
      displayMath: [ ['$$', '$$'], ["\\[","\\]"] ],
      processEscapes: true,
      processEnvironments: true,
      digits: /^(?:[0-9]+(?:\{,\}[0-9]{3})*(?:\.[0-9]*)?|\.[0-9]+)/,
      tags: 'none',  
      tagSide: "right",
      tagIndent: ".8em",
      multlineWidth: '85%',
      equationNumbers: {
        autoNumber: "AMS",
      },
      unicode: {
        fonts: "STIXGeneral,'Arial Unicode MS'"
      },
      autoload: expandable({
        mhchem: ['ce', 'pu']
      }
    },
    displayAlign: "left",
    showProcessingMessages: false,
    messageStyle: "none"
  };
The contents of your mkdocs.yml
nav:

theme:
    name: 'material'

plugins:
    - search
extra_javascript:
    - 'javascripts\mathjax.js'
    - 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
 #   - 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js'
 #   - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'
markdown_extensions:
    - toc:
        permalink: "¶"
    - markdown.extensions.admonition:
    - pymdownx.arithmatex
    - pymdownx.details
    - pymdownx.superfences
    - pymdownx.mark:
        smart_mark: false

System information

  • OS: windows7
  • Browser: Firefox/Chrome

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
facelessusercommented, Mar 4, 2020
  1. MathJax 3 is just now out of preview stage, but it can be supported.
  2. This is not a MkDocs issue, but is a user configuration issue: https://github.com/facelessuser/pymdown-extensions/issues/692
  3. If you check out the docs, there is some guidance on Mathjax 3 configuration: https://facelessuser.github.io/pymdown-extensions/extensions/arithmatex/#loading-mathjax.

If none of that helps, you can create an issue of at pymdown-extensions. As 3 is finally official, I will most likely migrate pymdown-extension documents over to using it and will document changes, if any are required.

0reactions
facelessusercommented, Mar 6, 2020

I am using $...$ in the Arithmatex docs with MathJax 3 and it works just fine. Please create an issue and post how you are configuring things as this is most likely a user error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mathjax inline mode not rendering [closed]
$ -style inline mode by inserting the following code into the <head> section of your HTML before MathJax is being loaded. This way,...
Read more >
Why is Mathjax not rendering inline equations in ioslides?
I am putting together my first ioslides presentation in R Studio and discovered that inline equations are not rendered properly in the ......
Read more >
TeX and LaTeX math delimiters
for displayed equations, but it does not define $...$ as in-line math delimiters. That is because dollar signs appear too often in non-mathematical...
Read more >
The line break(\\) is not work · Issue #2312 · mathjax ...
The line-break isn't effect and it renders as single line. However, it works fine and renders as two lines at verision 2.
Read more >
Rendering Math from RMarkdown
My posts that include math equations were written in R markdown. ... MathJax; Protecting display math equations; Enabling inline math ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found