pressbooks / pb-mathjax

A replacement for wp.com/latex.php but instead of LaTeX, it uses MathJax.
GNU General Public License v3.0
4 stars 1 forks source link

Can't use \left\{ and \begin{array} commands in conjunction with each other #27

Closed SteelWagstaff closed 4 years ago

SteelWagstaff commented 4 years ago

Users are unable to use \left\{ and \begin{array} commands successfully in the same mathematical expression with Pressbooks/MathJax. I can make each separately without issue (see examples 2 and 3 here: https://integrations.pressbooks.network/algebratest/chapter/problem-equations/), but when users try to combine them both, Pressbooks/MathJax fails to produce expected output. This is true of the webbook as well as file exports.

Example output: \left\{ \begin{array}{rrrrr} y&=&-3&& \\ y&=&-x&-&4 \right. \end{array} Screenshot from 2020-05-05 15-28-00

Expected output (produced with WP QuickLaTeX):
Screenshot from 2020-05-05 15-26-52

pkra commented 4 years ago

\left\{ \begin{array}{rrrrr} y&=&-3&& \\ y&=&-x&-&4 \right. \end{array}

The \right. needs to be outside the array as well (and all others seem to be like this).

\left\{ \begin{array}{rrrrr} y&=&-3&& \\ y&=&-x&-&4 \end{array} \right.

It's not actually valid otherwise and (real) LaTeX will at least (i.e., in nonstopmode) spew out a warning.

SteelWagstaff commented 4 years ago

Thanks @pkra -- fixing that looks like it may resolve the issue. Looking more like user syntax error at this point. This may be a silly question, but is there a free online LaTeX validator or similar tool I can use for future issues like this?

pkra commented 4 years ago

This may be a silly question, but is there a free online LaTeX validator or similar tool I can use for future issues like this?

On the one hand, MathJax throws you a bit of a curveball here since the combined configurations include the noError extension. Otherwise, you'd get a reasonable error that will match TeX's error messages when possible ("Missing \left or extra \right"). Here's an old MathJaxv2 CodePen of mine.

On the other hand, you probably want a "real" TeX environment. I usually do quick tests like this on https://www.overleaf.com. It allows easy access to the logs. While TeX error messages can be obscure (thanks to macro resolution), you'll at least know there is an error or warning, even if TeX recovers gracefully to create reasonable visual output.

In my experience, the main trouble with user reports based on "real" TeX tends to be the packages they use (cf. the issue about packages like polynom). Ideally, the user would provide a mimimal working TeX document that you can copy to overleaf.

SteelWagstaff commented 4 years ago

Closing issue -- syntax error, not a bug. Thanks again @pkra !