Aligned equations in LaTeX
Instead of aligned
, I would suggest an align
environment; \notag
can be used to suppress the tag for selected lines; the alignment for the second line can be produced with the help of a \phantom
:
\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amsthm, amssymb}
\usepackage[ansinew]{inputenc}
\begin{document}
\begin{align}
\alpha &= 1 + 2 \\
&\phantom{{}=1}-3 + 4 \notag\\
&= 4 \\
&=5-1,
\end{align}
\end{document}
- There should be an equation label for each equality sign, so 3 in total. At the moment there is only one
By using equation
and the sub-environment aligned
, you told it to generate only one equation number for the entire block. To get an equation number for each line, you can use for example the align
environment. You can suppress equation numbers for any line therein with the \nonumber
command. Alternatively, you can get vertically centered equation numbers for broken equations by using the split
sub-environment for these.
Using split
unfortunately has the problem that you need manual spacing to align the second part of the broken equation as desired, but if you only want it to be indented enough to clearly indicate it's a continuation of the line above, a \qquad
produces good results.
\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amsthm, amssymb}
\usepackage[ansinew]{inputenc}
\begin{document}
\begin{align}
\begin{split}
\alpha &= 1 + 2 \\
& \qquad - 3 + 4
\end{split} \\
&= 4 \\
&=5-1,
\end{align}
\end{document}
produces something that to me looks good.
- The "+2" and "-3+4"-parts are aligned right, which distorts the whole equation. I'm not quite sure why it is doing that, I haven't told it explicitly to do so.
You did. I'm not 100% sure how exactly align
and alignment
interpret multiple &
markers, but as far as I can tell, they cause alternating right- and left-alignment in each column, so your code placed them left-aligned in the rightmost of four columns. You can push them further left by adding some hspace*
after any of the two parts, but that will not push them further left than the right end of any other second column in the environment.
I recommend align
and split
.
EDIT: The aforementioned code looks like
I always use the alignat
environment for that.
I used \notag
to have no equation number in the first line.
Code
\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amsthm, amssymb}
\usepackage[ansinew]{inputenc}
\begin{document}
\begin{alignat}{2}
\alpha & = 1 && {} + 2 \notag \\
& && {} - 3 + 4 \\
& = 4 && \\
& = 5 - 1
\end{alignat}
\end{document}