# Alignment points in math equation

I'm trying to align the following "equation":

\begin{equation*}
\begin{split}
A_G &= [ \text{E.id, E.name, E.rank,} \\
&= [ 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1 ]
\end{split}
\end{equation*}


which looks like this:

As one can see, the broken lines don't align well -- I'd like to have "P.rank" and "S.code" both left-align to "E.id". How can one achieve this?

In this case you could use align to align.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
A_G = [& \text{E.id, E.name, E.rank,} \\
&  \text{P.rank, P.title, P.code,} \\
&  \text{S.code, S.amount} ] \\
= [& 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1 ]
\end{align*}
\end{document}


• Thanks! I was trying some stuff with multiple alignment points -- all attempts failed. In general how would multiple alignments work?
– Covi
Jul 30, 2018 at 5:27

Here's a solution that uses (a) a \parbox directive to typeset the text material -- no need to insert line breaks by hand and hence to worry about alignment points -- and (b) a bmatrix environment to typeset the row vector.

I chose the width of the \textbox -- 4cm -- so that it reproduces the number of line breaks (2) that appear in the OP's screenshot. By setting the width of the box to 5.5cm, say, the number of line breaks would be reduced from 2 to just 1.

\documentclass{article}
\usepackage{amsmath}
% handy utility macro (the default width is 4cm):
\newcommand\textbox[2][4cm]{\parbox[t]{#1}{\raggedright #2}}

\begin{document}
\begin{equation*}
\begin{split}
A_G &= [\textbox{E.id, E.name, E.rank, P.rank, P.title, P.code, S.code, S.amount]} \\
&= \begin{bmatrix}
1 & 1 & 1 & 1 & 1 & 1 & 1 & 1
\end{bmatrix}
\end{split}
\end{equation*}
\end{document}


Since the material is textual, I suggest tabular (it would be array if the material were math); this also uses less vertical space.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
A_G &= [
\begin{tabular}[t]{@{}l@{}}
E.id, E.name, E.rank, \\
P.rank, P.title, P.code, \\
S.code, S.amount$]$
\end{tabular}
\\
&= \begin{bmatrix} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \end{bmatrix}
\end{align*}

\end{document}