Solving Latex (MathJax) Bug - Partial Derivatives

In summary: Although "eqnarray" is deprecated, it's still supported in MathJax. This means that you can use it in conjunction with MathJax's other environment options, such as "array" and "matrix". Memo to self: next time, try it in a "real" tex environment before you decide it's a PF problem!
  • #1
AlephZero
Science Advisor
Homework Helper
6,982
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
[tex]\begin{array}
\frac {\partial}{\partial a^1} = \cdots \\
\frac {\partial}{\partial a^2} = \cdots \\
\frac {\partial}{\partial a^3} = \cdots
\end{array}
[/tex]

I found a workround, namely to change the first line to
Code:
{} \frac {\partial}{\partial a^1} = \cdots \\
which does work:
[tex]\begin{array}
{} \frac {\partial}{\partial a^1} = \cdots \\
\frac {\partial}{\partial a^2} = \cdots \\
\frac {\partial}{\partial a^3} = \cdots
\end{array}
[/tex]
 
Physics news on Phys.org
  • #2
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
[tex]\begin{array}{r}
\frac {\partial}{\partial a^1} = \cdots \cdots \\
\frac {\partial}{\partial a^2} = \cdots \\
\frac {\partial}{\partial a^3} = \cdots
\end{array}[/tex]

Not a bug!

(Although it would be nice if MathJax gave a proper error.)
 
  • #3
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!
 
  • #4
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.
 
  • #5
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}
[tex]\begin{align}
\frac {\partial}{\partial a^1} &= \cdots \\
\frac {\partial}{\partial a^2} &= \cdots \\
\frac {\partial}{\partial a^3} &= \cdots
\end{align}[/tex]
With the AMS math environments (align, gather, multline, matrix, etc.) there's almost never any reason to use array or especially eqnarray anymore.
 
  • #6
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.
 
  • #7
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:

FAQ: Solving Latex (MathJax) Bug - Partial Derivatives

How do I fix incorrect rendering of partial derivatives in Latex/MathJax?

One common reason for incorrect rendering of partial derivatives is the use of incorrect syntax. Make sure to use the correct notation for partial derivatives, which is \frac{\partial}{\partial x} for a partial derivative with respect to x. Also, check for any missing or misplaced parentheses in your expression.

Why is the partial derivative symbol not showing up in my Latex/MathJax equation?

If the partial derivative symbol is not showing up, it could be due to a missing or incorrect package. Make sure to include the "amsmath" package in your document header, as it contains the necessary commands for partial derivatives. If the issue persists, try clearing your browser's cache or using a different browser.

How can I display partial derivatives with multiple variables in Latex/MathJax?

To display partial derivatives with multiple variables, use the notation \frac{\partial}{\partial x}\frac{\partial}{\partial y} for a partial derivative with respect to both x and y. Make sure to include the necessary parentheses and use the correct order of variables in your expression.

My partial derivative equation is not aligning properly, what can I do?

If your partial derivative equation is not aligning properly, it could be due to missing or incorrect alignment symbols. Use the "&" symbol to indicate the points of alignment in your equation. You can also use the "aligned" environment to align multiple equations within a single equation.

Is there a way to customize the appearance of partial derivatives in Latex/MathJax?

Yes, there are several options for customizing the appearance of partial derivatives in Latex/MathJax. You can change the size of the partial derivative symbol, add a subscript or superscript, and change the font style. Check the documentation for your specific Latex/MathJax package to see the available customization options.

Similar threads

Back
Top