5
$\begingroup$

The equations below: $$\begin{align} \sum_{i=1}^n F_{2i-1}&=F_1+F_3+F_5+\cdots+F_{2n-1}\\ &=1+2+5+\cdots+F_{2n-1}\\ &=F_{2n}\\ \end{align} $$ have a problem with too much space between the first and second lines—at least that's how it displays in Opera. The code is below:

$$\begin{align}
\sum_{i=1}^n F_{2i-1}&=F_1+F_3+F_5+\cdots+F_{2n-1}\\
&=1+2+5+\cdots+F_{2n-1}\\
&=F_{2n}\\
\end{align}
$$

Is there a way to ajdust the vertical space in MathJaX?

$\endgroup$
8
$\begingroup$

Another possibility is to use \smash to stop MathJAX from adjusting the line spacing to accomodate mathematical expressions:

$$\begin{align} \smash{\sum_{i=1}^n}F_{2i-1}&=F_1+F_3+F_5+\cdots+F_{2n-1}\\ &=1+2+5+\cdots+F_{2n-1}\\ &=F_{2n}\\ \end{align} $$

$$\begin{align} \smash{\sum_{i=1}^n}F_{2i-1}&=F_1+F_3+F_5+\cdots+F_{2n-1}\\ &=1+2+5+\cdots+F_{2n-1}\\ &=F_{2n}\\ \end{align} $$

$\endgroup$
  • $\begingroup$ \smash worked perfectly! Thank you! $\endgroup$ – Brian J. Fink May 9 '14 at 20:54
  • $\begingroup$ I'm not sure why, but smash in your screenshot has adjusted the spacing within the sum (as compared to the other screenshots) in that the F is closer to the summation symbol. It doesn't do so in latex...might be a mathjax thing? $\endgroup$ – Scott H. May 9 '14 at 20:59
  • $\begingroup$ Also, just FYI (not necessarily for your information, but for others reading that might not know) I'm not sure if they're implemented in mathjax, but the latex smash has optional arguments: \smash[t]{stuff} has zero height above the baseline, while \smash[b]{stuff} has zero depth below the baseline. In some cases you might want to retain the height or depth while "smashing" the other. $\endgroup$ – Scott H. May 9 '14 at 21:07
  • $\begingroup$ @Scott, that solves the other issue I had when I first implemented it—namely the collapsing of the line feed above the first line. Also helpful. Can we use \smash[r] or \smash[l] as well? $\endgroup$ – Brian J. Fink May 9 '14 at 21:16
  • $\begingroup$ @BrianJ.Fink In latex there are \llap{stuff} and \rlap{stuff} but I'm not sure they work in mathmode (or if there are corresponding mathmode versions). The mathtools package provides \mathrlap etc. so you could try loading that package in mathjax to see if it works. $\endgroup$ – Scott H. May 9 '14 at 21:23
  • $\begingroup$ @Scott I meant "it--namely," but the dash didn't translate. $\endgroup$ – Brian J. Fink May 9 '14 at 21:23
  • $\begingroup$ @Scott MathJaX does have \llap and \rlap, but they make the text completely overlap the text next to it. $\endgroup$ – Brian J. Fink May 9 '14 at 21:26
  • $\begingroup$ @BrianJ.Fink That's the intent! You're "smashing" the width (?) of the text from the left/right in the same way that smash does vertically. The difference being that with vertical smashing you have the natural line height to provide some buffer space whereas horizontally you don't. $\endgroup$ – Scott H. May 9 '14 at 21:32
  • $\begingroup$ @Scott Good eye with that $F$ in the summation. I discovered that if I enclose the $F_{2i-1}$ along with the $\sum$, the issue is resolved. $\endgroup$ – Brian J. Fink May 9 '14 at 22:44
4
$\begingroup$

You can adjust the space in a line break with \\[10pt] $$ \begin{align} \sum_{i=1}^n F_{2i-1}&=F_1+F_3+F_5+\cdots+F_{2n-1}\\ &=1+2+5+\cdots+F_{2n-1}\\[10pt] &=F_{2n}\\ \end{align} $$ Right-click on the rendered MathJax and choose "Show Math As > TeX Commands"

$\endgroup$
  • $\begingroup$ This is very helpful. Do you mind if I essentially copy and paste the first line of this answer into the end of the answer about the align environment on the big Mathjax formatting thread? I think I searched the web only to be directed right back here. $\endgroup$ – pjs36 Jan 9 '17 at 21:22
  • $\begingroup$ Sure, however, David K has added a comment with a bit more detail. You might want to include some of that detail as well. $\endgroup$ – robjohn Apr 11 '17 at 15:29
3
$\begingroup$

The reason why the space is different is because of the $i=1$ under the sigma symbol. Let's write this without the $i=1$ and see how it would look. $$\begin{align} \sum^n F_{2i-1}&=F_1+F_3+F_5+\cdots+F_{2n-1}\\ &=1+2+5+\cdots+F_{2n-1}\\ &=F_{2n}\\ \end{align} $$ See, now the spacing is the same. Now I will show you how to make the spacing the same if it is ever different. $$\begin{align} \sum_{i=1}^n F_{2i-1}&=F_1+F_3+F_5+\cdots+F_{2n-1}\\ &=1+2+5+\cdots+F_{2n-1}\\[10pt] &=F_{2n}\\ \end{align} $$ Simply add \\[10pt] between the code for the second line and the third line to space out the lines. Note that it will not always be \\[10pt]. For something like $\lim\limits_{x\to 1}$, then it will be something else.

$\endgroup$

You must log in to answer this question.

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