CodeMirror-MathJax icon indicating copy to clipboard operation
CodeMirror-MathJax copied to clipboard

MathJax state: \newcommand and friends, numbered eqs

Open cben opened this issue 12 years ago • 8 comments

cben avatar Jul 27 '13 21:07 cben

Turns out MathJax has stateful support for \newcommand, and it works. However it depends on the order they're typeset, which might not correspond to document order To make it usable:

  • [x] Leave $\newcommand{...}$ in source form instead of becoming invisible (special case of #10).
  • [ ] on change to a $\newcommand...$ formula, re-typeset all (or all following) math.

cben avatar Sep 14 '13 01:09 cben

  • [x] Also pass \[re]newcommand... without any $ etc delimiters to mathjax. Pandoc does this.

cben avatar Sep 25 '13 08:09 cben

Undocumented: \newcommand alters MathJax.InputJax.TeX.Definitions.macros and MathJax.InputJax.TeX.Definitions.environment. Could try to save/restore them instead of re-typesetting all following math. However, it's rare enough that re-typesetting should be acceptable.

cben avatar Oct 28 '13 23:10 cben

Simular (but worse?) issues of rendering order sensitivity happen with \begin{equation} numbering. See https://github.com/mathjax/MathJax/issues/422.

This is going to be more acute if I optimize initial pass (#14) to be partial/out-of-order.

  • [ ] Learn which phase of MJ updates state (macros, numbers, labels). Preprocess? Process? Render?

cben avatar Nov 22 '13 10:11 cben

http://jsfiddle.net/89r6p/3/ demonstates mathjax running again (click) on labels, numbers & refs.

cben avatar Nov 22 '13 10:11 cben

Numbering state is in MathJax.Extension["TeX/AMSmath"].number and MathJax.Extension["TeX/AMSmath"].startNumber; there is a host of other variables to handle labels&refs: https://github.com/mathjax/MathJax/blob/master/unpacked/extensions/TeX/AMSmath.js#L562

cben avatar Feb 11 '14 08:02 cben

  • [ ] syntax highlight \begin...\end
  • [ ] syntax highlight \newcommand...}
  • [ ] avoid "label foo multiply defined" which makes labels completely unusable

cben avatar Feb 12 '14 01:02 cben

  • [ ] handle \DeclareMathOperator not wrapped in $...$
    • [ ] handle any tex macros not wrapped in math? Probably WONTFIX.

Should check how pandoc handles those.

cben avatar Feb 12 '14 09:02 cben