I have this MathJax sequence that I want to format properly in MathOverflow:
$$S_m = \begin{cases} \begin{aligned} 1, \quad\text{for m=1}\\ 12, \quad\text{for m=2}\\ 123, \quad\text{for m= 3}\\ 1234, \quad\text{for m= 4}\\ 12345, \quad\text{for m= 5}\\ 123456, \quad\text{for m= 6}\\ 1234567, \quad\text{for m= 7}\\ 12345678, \quad\text{for m= 8}\\ 123456789, \quad\text{for m= 9}\\ 1234567890, \quad\text{for m=10}\\ 12345678901, \quad\text{for m=11}\\ 12345678901..., \quad\text{for m>11}\\ S_{m-1} \times 10 + (m \bmod 10), \quad\text{for m>11}\\ \end{aligned} \end{cases} $$
$$S_m =
\begin{cases}
\begin{aligned}
1, \quad\text{for m=1}\\
12, \quad\text{for m=2}\\
123, \quad\text{for m= 3}\\
1234, \quad\text{for m= 4}\\
12345, \quad\text{for m= 5}\\
123456, \quad\text{for m= 6}\\
1234567, \quad\text{for m= 7}\\
12345678, \quad\text{for m= 8}\\
123456789, \quad\text{for m= 9}\\
1234567890, \quad\text{for m=10}\\
12345678901, \quad\text{for m=11}\\
12345678901..., \quad\text{for m>11}\\
S_{m-1} \times 10 + (m \bmod 10), \quad\text{for m>11}\\
\end{aligned}
\end{cases}
$$
However, it is rendered as follows (in the below screenshot):
For $m=1$ to $m=9$ the formatting of "for" is left-indented as compared to $m=10$, $m=11$, and $m>11$.
I tried padding the "\text" statements with spaces but I was not successful.
From the link on how to add white space, it seems that this issue needs to be treated very carefully to allow rendering to complete as best-possible in multiple scenarios.
Update - My Homework : I received comment support from @Emil Jeřábek and also checked the Stack Exchange Overflow reference Aligning multiple equations in MathJax. Using the support and also the "Aligning multiple equations in MathJax, I updated the MathJax equation and now it renders as:
The MathJax text is as follows:
$$S_m =
\begin{cases}
\begin{aligned}
1, \quad \text{for m=} & 1\\
12, \quad \text{for m=} & 2\\
123, \quad \text{for m=} & 3\\
1234, \quad \text{for m=} & 4\\
12345, \quad \text{for m=} & 5\\
123456, \quad \text{for m=} & 6\\
1234567, \quad \text{for m=} & 7\\
12345678, \quad \text{for m=} & 8\\
123456789, \quad \text{for m=} & 9\\
1234567890, \quad \text{for m=} & 10\\
12345678901, \quad \text{for m=} & 11\\
12345678901..., \quad \text{for m>} & 11\\
S_{m-1} \times 10 + (m \bmod 10), \quad \text{for m>} & 11\\
\end{aligned}
\end{cases}
$$
I saw in the Stack Overflow article Aligning multiple equations in MathJax that the recommended equation layout is as follows:
So I updated the layout as follows:
The updated MathJax text follows.
$$S_m =
\begin{cases}
\begin{aligned}
1, \quad \text{for m = } & 1\\
12, \quad \text{for m = } & 2\\
123, \quad \text{for m = } & 3\\
1234, \quad \text{for m = } & 4\\
12345, \quad \text{for m = } & 5\\
123456, \quad \text{for m = } & 6\\
1234567, \quad \text{for m = } & 7\\
12345678, \quad \text{for m = } & 8\\
123456789, \quad \text{for m = } & 9\\
1234567890, \quad \text{for m = } & 10\\
12345678901, \quad \text{for m = } & 11\\
12345678901..., \quad \text{for m > } & 11\\
S_{m-1} \times 10 + (m \bmod 10), \quad \text{for m > } & 11\\
\end{aligned}
\end{cases}
$$
What is left to my question about how to format the sequence?
With the previously comments from @Emil Jeřábek, there was the recommendation that perhaps "begin{cases}" is not required, and he was surprised that this equation was rendering at all, if I understood his comment properly.
But for me, if I do not include the begin{cases} and end{cases} then the left bracket does not render at all (with FireFox).
The question still stands as to whether my MathJax updated text is the recommended route or if further MathJax text modifications are recommended or are necessary to prevent other rendering problems.
The only reference that I have found for the left bracket is here from the Stack Exchange Superuser Site Article "Using the cases environment in LyX" - for which Lyx is a LatTex front-end:
\begin{cases}
1st\\
2nd\\
3rd\end{cases}
In this MathJax environment, it renders as follows:
$$\begin{cases} 1st\\ 2nd\\ 3rd\end{cases}$$
I still have not found a reference for other techniques for casting the left bracket, but I hope that updated comments or answers might provide the referenced links (preferably from the Stack Exchange web-sites) to get a better idea of the Stack Exchange recommended practice.
What else is recommended or needed to render the equation properly under the multiple supported browsers?
&
(including the fact that it goes in front of $=$ signs rather than after them). It does not suggest to omit the&
, nor does it suggest mixingaligned
withcases
. $\endgroup$\text{for m=4}
) but rather $\text{“for } m = 4\text{”}$ (coded as\text{for } m=4
). The thing that causes you to think that one font looks good and another looks terrible consists precisely of a large number of little things of just that kind. And Donald Knuth invented TeX (the ancestor of MathJax) with precisely that in mind. $$ \begin{align} \text{wrong: } & \text{for m=4} \\ \text{right: } & \text{for } m=4 \end{align} $$ $\endgroup$12345678901...
, but rather12345678901\ldots
. In LaTeX (as opposed to MathJax) the latter will appear as $12345678901\text{...}$ rather than $12345678901\ldots \qquad$ $$\begin{align} & 12345678901\text{...} \\ & 12345678901\ldots \end{align} $$ The first version above is incorrect. $\endgroup$&
after=
instead of before, as long as you insert an atom:1 ={} & 2
. This has come in handy for me in non-artificial circumstances where putting the=
where the AMS expects would have taken significant re-arrangement. $\endgroup$