1

This question arose when I wanted to wrap a very long equation inside the align environment. I found that if the ampersand was used to the left of the equal sign, the next line of the wrapped equation was shifted too much to the left (eq. 3-4).

So I moved the ampersand to the right of the equal sign, which fixed the alignment of the wrapped portion (eq. 6), but also swallowed the space after the equal signs (eq. 1). I fixed that with an ugly hack - by adding \enskip (eq. 2).

\documentclass{scrartcl}
\usepackage{amsmath}

\begin{document}

\begin{align}
p(x=20)&=1\left(0.45\right)^{20}\left(0.55\right)^{0}\\
p(x=20)=\enskip &0.0000001159\\
p(x>14)&=0.004903+0.001254+0.0002413+0.00003291+0.000002834+\phantom{ }\\
&+0.0000001159=0.006434=0.6\%\\
p(x>14)=\enskip &0.004903+0.001254+0.0002413+0.00003291+0.000002834+\phantom{ }\\
&+0.0000001159=0.006434=0.6\%
\end{align}

\end{document}

That was when I also noticed, that the space before the very last plus sign at the end of the line to be wrapped also disappeared (eq. 3). I fixed that with another ugly hack - by adding `\phantom{} (eq. 5)

Why did those spaces disappear in the first place, and what is the proper way to preserve them?

enter image description here

1

You can split the long equation:

\documentclass{scrartcl}
\usepackage{amsmath}

\begin{document}

\begin{align}
p(x=20) &= 1(0.45)^{20}(0.55)^{0} \\
p(x=20) &= 0.0000001159 \\
\begin{split}
p(x>14) &= 0.004903+0.001254+0.0002413+0.00003291 \\
        & \qquad +0.000002834+0.0000001159 \\
        &= 0.006434 = 0.6\%
\end{split}
\end{align}

\end{document}

The continuation line starts right of the equals sign, so it's clearly distinguishable.

I removed \left and \right that do nothing sensible.

enter image description here

4

math operators = and + are not the same sort, they differs in spacing around them. a trick, which can help you is:

\documentclass{scrartcl}
\usepackage{mathtools}
\usepackage{siunitx}

\begin{document}
\begin{align}
p(x=20) & = 1\left(0.45\right)^{20}\left(0.55\right)^{0}\\
p(x=20) & = 0.0000001159\\
\begin{split} % for one number of equation
p(x>14) & = 0.004903+0.001254+0.0002413+0.00003291+0.000002834+{}\\
        &\, + 0.0000001159=0.006434=\SI{0.6}{\%}
\end{split}
\intertext{I more prefer the following formatting:}
p(x>14) & = \begin{multlined}[t]
            0.004903+0.001254+0.0002413+0.00003291+{}\\
          + 0.000002834+ 0.0000001159=0.006434=\SI{0.6}{\%}
            \end{multlined}
\end{align}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.