2
$\begingroup$

MathJax should theoretically support \begin{eqnarray} \end{eqnarray} statements and have proper alignment with multi-line equations.

See for example Testing MathJax (LATEX in your blogposts!).

If I copy the last example I get:

\begin{eqnarray} f_p(x) & = & \sum_{j=0}^{n} c_j \phi(||x - x_j||) \ & = & \sum_{j=0}^{n} c_j \phi_j(x) \ & = & c_0 \phi_0(x) + c_1 \phi_1(x) + \cdots + c_n \phi_n(x) \end{eqnarray}

which makes it complicated to introduce longer equations.

$\endgroup$
  • $\begingroup$ You need to use \\ or \cr to end the lines in your equation. I suspect that they may have been eaten by the mini-Markdown formatter before MathJax got to see them. $\endgroup$ – Davide Cervone May 8 '11 at 1:59
  • $\begingroup$ I'd write $\|x-x_j\|$ rather than $||x-x_j||$. If that difference is not conspicuous enough for you, look at $\|a\|\|b\|$ (coded as \|a\|\|b\|) versus $||a|| ||b||$ (coded as ||a|| ||b||). $\qquad$ $\endgroup$ – Michael Hardy Dec 27 '16 at 1:09
4
$\begingroup$

The statement will be rendered properly if you wrap the whole eqnarray block in double dollar signs.

That is, $$\begin{eqnarray} f_p(x) & = & \sum_{j=0}^{n} c_j \phi(||x - x_j||) \\ & = & \sum_{j=0}^{n} c_j \phi_j(x) \\ & = & c_0 \phi_0(x) + c_1 \phi_1(x) + \cdots + c_n \phi_n(x) \end{eqnarray}$$

$\endgroup$
  • $\begingroup$ Thanks, I thought that using dollar signs with \begin \end statements is redundant, but it seems to matter. $\endgroup$ – Karol J. Piczak May 9 '11 at 20:21
  • $\begingroup$ The dollar signs ARE redundant, and DON'T make a difference. The display is properly typeset as a display equation, so it has nothing to do with that. It is the fact that your line ends with a single slash not a double slash, so they have become the control sequence "slash-space" which forces a space, but not a line break. So there are no line breaks in your expression, and MathJax has properly rendered it. If you use the MathJax contextual menu to show the TeX source you will see that the double slashes are missing (there are only single slashes). $\endgroup$ – Davide Cervone May 10 '11 at 20:18
  • 1
    $\begingroup$ (If using double dollars does make a difference, then it may because the mini-markdown used by StackExchange alters its escaping rules within double dollars, so the double-slash you typed STAYS a double-slash, whereas without the double-dollars slashes are used for escaping special characters (like slashes) and so the double-slash is translated to a single slash by the system. In any case, the reason you are not getting line breaks is because MathJax doesn't see any double-slashes in your equation.) $\endgroup$ – Davide Cervone May 10 '11 at 20:21
  • 1
    $\begingroup$ That's exactly the case. Thanks for pointing this out. If you check the source of the post it's correct (double slashes). Not wrapping it in double dollars indeed converts all double slashes into single slash when plugging into MathJax renderer. $\endgroup$ – Karol J. Piczak May 10 '11 at 21:29
  • 3
    $\begingroup$ olaker please improve your answer with showing the code. I have not enough reputation to click "edit" and see the mathjax code myself. $\endgroup$ – Tomas Jul 22 '13 at 6:12
  • $\begingroup$ Same comment here that I made under the question. $\endgroup$ – Michael Hardy Dec 27 '16 at 1:10
1
$\begingroup$

I tried to put this calculation in FaceBook ( the $\tt LaTeX$ code is below the rendering ). I used one of the ${\rm\mbox{bookmarklets}}$ $\tt startChatjax$ o $\tt render Mathjax$ which are given in this page and it doesn't work.

However, if I reduces the code to a few lines it works. I don't understand yet what is going on.

\begin{eqnarray*} I_{n} & = & \int_{0}^{1}\ldots\int_{0}^{1}\ln\left(1 - x_{1}x_{2}\ldots x_{n}\right) \,{\rm d}x_{1}\,{\rm d}x_{2}\ldots{\rm d}x_{n} \\[3mm]& = & \int_{0}^{1}\ldots\int_{0}^{1} \sum_{k = 1}^{\infty}{-1 \over k} \left(x_{1}x_{2}\ldots x_{n}\right)^{k} \,{\rm d}x_{1}\,{\rm d}x_{2}\ldots{\rm d}x_{n} \\[3mm]&=& -\sum_{k = 1}^{\infty}{1 \over k\left(k + 1\right)^{n}} =-\sum_{k = 1}^{\infty} {1 \over k\left(k + 1\right)^{n - 1}} +\sum_{k = 1}^{\infty}{1 \over \left(k + 1\right)^{n}} \\[3mm]&=& I_{n - 1} +\sum_{k = 1}^{\infty}{1 \over k^{n}} - 1 = I_{n - 1} + \zeta\left(n\right) - 1 \end{eqnarray*}

\begin{eqnarray*}
I_{n} & = &
\int_{0}^{1}\ldots\int_{0}^{1}\ln\left(1 - x_{1}x_{2}\ldots x_{n}\right)
\,{\rm d}x_{1}\,{\rm d}x_{2}\ldots{\rm d}x_{n}
\\[3mm]& = &
\int_{0}^{1}\ldots\int_{0}^{1}
\sum_{k = 1}^{\infty}{-1 \over k}
\left(x_{1}x_{2}\ldots x_{n}\right)^{k}
\,{\rm d}x_{1}\,{\rm d}x_{2}\ldots{\rm d}x_{n}
\\[3mm]&=&
-\sum_{k = 1}^{\infty}{1 \over k\left(k + 1\right)^{n}}
=-\sum_{k = 1}^{\infty}
{1 \over k\left(k + 1\right)^{n - 1}}
+\sum_{k = 1}^{\infty}{1 \over \left(k + 1\right)^{n}}
\\[3mm]&=&
I_{n - 1}
+\sum_{k = 1}^{\infty}{1 \over k^{n}} - 1
=
I_{n - 1} + \zeta\left(n\right) - 1
\end{eqnarray*}
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .