Solving Latex (MathJax) Bug - Partial Derivatives

  • Context: LaTeX 
  • Thread starter Thread starter AlephZero
  • Start date Start date
  • Tags Tags
    Bug Latex Mathjax
Click For Summary

Discussion Overview

The discussion revolves around issues encountered with LaTeX (MathJax) when using the "array" environment for partial derivatives. Participants explore the proper usage of various environments for typesetting equations, including "array," "matrix," and "align." The focus is on identifying bugs, workarounds, and best practices in mathematical typesetting.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant reports a problem with the "array" environment not functioning as expected for partial derivatives and suggests a workaround by adding an empty brace.
  • Another participant clarifies that the "array" environment requires an alignment directive as its first argument, indicating that the issue is not a bug.
  • A participant admits to mistakenly using "array" instead of "matrix," suggesting that testing in a proper LaTeX environment could prevent such errors.
  • There is a recommendation to use the "align" environment for equations, with a participant questioning the reasoning behind this preference.
  • Concerns are raised about the dependency on AMS environments, with one participant expressing a desire for an environment that "always works" across different platforms.
  • Another participant provides references to reasons why "eqnarray" is deprecated, discussing layout problems and asserting that AMS environments are generally superior for typesetting.

Areas of Agreement / Disagreement

Participants express differing views on the best environments to use for typesetting equations, with some advocating for "align" and others questioning its necessity. There is no consensus on a single preferred environment, as various options are deemed eligible depending on the context.

Contextual Notes

Some participants note that the effectiveness of different environments may depend on the specific LaTeX implementation or platform being used, which could influence the choice of environment.

AlephZero
Science Advisor
Homework Helper
Messages
6,998
Reaction score
299
This doesn't work properly:

Code:
\begin{array} 
\frac {\partial}{\partial a^1} = \cdots \\
\frac {\partial}{\partial a^2} = \cdots \\
\frac {\partial}{\partial a^3} = \cdots
\end{array}

It gives
\begin{array} <br /> \frac {\partial}{\partial a^1} = \cdots \\<br /> \frac {\partial}{\partial a^2} = \cdots \\<br /> \frac {\partial}{\partial a^3} = \cdots<br /> \end{array}<br />

I found a workround, namely to change the first line to
Code:
{} \frac {\partial}{\partial a^1} = \cdots \\
which does work:
\begin{array} <br /> {} \frac {\partial}{\partial a^1} = \cdots \\<br /> \frac {\partial}{\partial a^2} = \cdots \\<br /> \frac {\partial}{\partial a^3} = \cdots<br /> \end{array}<br />
 
Physics news on Phys.org
That's because the "array" environment expects an alignment directive as its first argument:

Code:
\begin{array}{r}
\frac {\partial}{\partial a^1} = \cdots \cdots \\
\frac {\partial}{\partial a^2} = \cdots \\
\frac {\partial}{\partial a^3} = \cdots
\end{array}

yields
\begin{array}{r}<br /> \frac {\partial}{\partial a^1} = \cdots \cdots \\<br /> \frac {\partial}{\partial a^2} = \cdots \\<br /> \frac {\partial}{\partial a^3} = \cdots<br /> \end{array}

Not a bug!

(Although it would be nice if MathJax gave a proper error.)
 
Actually, the real bug was typing "array" when I meant "matrix". Oh well, we all get brain-fade sometimes.

Memo to self: next time, try it in a "real" tex environment before you decide it's a PF problem!
 
Another memo (that I had already written to myself before :wink:):
If the first symbol for some reason doesn't show, consider that perhaps tex expects an alignment directive there.
 
AlephZero said:
Actually, the real bug was typing "array" when I meant "matrix". Oh well, we all get brain-fade sometimes.

Memo to self: next time, try it in a "real" tex environment before you decide it's a PF problem!
If you were using it for equations, actually "align" is recommended:
Code:
\begin{align}
\frac {\partial}{\partial a^1} &= \cdots \\
\frac {\partial}{\partial a^2} &= \cdots \\
\frac {\partial}{\partial a^3} &= \cdots
\end{align}
\begin{align}<br /> \frac {\partial}{\partial a^1} &amp;= \cdots \\<br /> \frac {\partial}{\partial a^2} &amp;= \cdots \\<br /> \frac {\partial}{\partial a^3} &amp;= \cdots<br /> \end{align}
With the AMS math environments (align, gather, multline, matrix, etc.) there's almost never any reason to use array or especially eqnarray anymore.
 
diazona said:
If you were using it for equations, actually "align" is recommended:

What is the reasoning behind this recommendation?

Since I mostly post equations on forums, I'd prefer the environment that "always works".
Meaning I don't want to be dependent of (parts of) an AMS environment or another environment that may or may not be available.

As far as I can tell matrix, pmatrix, array, eqnarray, align all seem to work in various environments, so they are all eligible.
What I haven't yet figured out is why one would be preferable over another.
 
Reasons why eqnarray is deprecated: http://www.tug.org/pracjourn/2006-4/madsen/, http://texblog.net/latex-archive/maths/eqnarray-align-environment/, http://www.math.uiuc.edu/~hildebr/tex/displays.html (and much of the same reasoning applies to array). Basically it's because of layout problems - though to be fair, those aren't as much of an issue when rendering to MathML, as MathJax does. It might even be the case that MathJax implements array and eqnarray as synonyms for matrix and align (with slightly different syntax).

Still, it's pretty common knowledge throughout the LaTeX community that the AMS environments are strictly better than array and eqnarray when you're typesetting a paper, and no worse anywhere else, so you're unlikely to find any environment where they are not supported. (MathJaX supports all the AMS environments natively, and every LaTeX distribution includes the AMS packages, so I can't think of a legitimate reason you would be unable to use them. The website administrator would have had to explicitly disable them, which would be silly.)
 
Last edited by a moderator:

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 10 ·
Replies
10
Views
890
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
927
  • · Replies 20 ·
Replies
20
Views
802
  • · Replies 1 ·
Replies
1
Views
2K