# How to align some lines under {align*}

I usually use \begin{align*} and \end{align*} to align some texts. Here is a special case I would like to realize:

abcdefghijklmn
hijklmn
opqrstuvwxyz
hijklmn


There are 2 rules:

1) I want to left-adjust the 1st line and the 3rd line

2) I want to adjust the beginning of the 2nd line and 4th line to a special location of the 1st line (for instance under 'd').

Could anyone help? Thank you very much.

-

It's more usual to use tabular for text. The amsmath align* environment and friends are intended for equations (details here).

\documentclass{minimal}
\usepackage{amsmath}
\begin{document}
\setlength{\tabcolsep}{0pt} %Probably needed in document classes other than minimal.
\begin{tabular}{ll}
abc&defghijklmn \\
&hijklmn     \\
\multicolumn{2}{l}{opqrstuvwxyz}   \\
&hijklmn
\end{tabular}
%
\begin{align*}
\textrm{abc}&\textrm{defghijklmn} \\
&\textrm{hijklmn}     \\
\textrm{opq}&\textrm{rstuvwxyz}   \\
&\textrm{hijklmn}
\end{align*}
\end{document}


You can find more details of tabular in the Not So Short Guide to LaTeX.

-
Hello, Thanks for your comment. But I do not think it answers to my question: for the {align*} part, the 1st line and the 3rd line are not always left-adjusted; for the {tabular}{ll} part, I do not want to force the 2nd line and the 4th line to be aligned somewhere with the 3rd line... Hope my request is clear... – SoftTimur May 2 '11 at 10:30
By the way, what I write are usually formulas instead of texts, that is one reason why I use {align*} more often... – SoftTimur May 2 '11 at 10:34
I've fixed the solution with tabular. I don't have any more time now, but for equations I think you could try array instead of align*. – Ian Thompson May 2 '11 at 10:58
I get a gap between the parts of the first line. You should also do \setlength{\tabcolsep}{0pt} and then they will be flush. – Ryan Reich May 2 '11 at 13:22
@Ryan --- Thanks. In the minimal document class, tabcolsep is zero by default, so I missed this. – Ian Thompson May 3 '11 at 12:39

I know this will not be what you expect as you want to deal with math mode material (you should reformulate your question to make it clear), but a very simple-minded approach with the data given in your formulation would just be:

\documentclass{minimal}
\begin{document}
\noindent abcdefghijklmn\\
\phantom{abc}hijklmn\\
opqrstuvwxyz\\
\phantom{abc}hijklmn
\end{document}


For stuff in display math you should look at the amsldoc.pdf file which documents the environments provided by amsmath.

-
\documentclass{article}
\usepackage{mathtools} % first solution
\usepackage{array} % second solution
\begin{document}

\begin{alignat*}{2}
&abc&&defghijklmn \\
&&&hijklmn     \\
&\mathrlap{opqrstuvwxyz} \\
&&&hijklmn
\end{alignat*}

$\setlength{\arraycolsep}{0pt} \begin{array}{*{2}{>{\displaystyle}l}} abc&defghijklmn \\ &hijklmn \\ \multicolumn{2}{l}{opqrstuvwxyz} \\ &hijklmn \end{array}$

\end{document}


However, a real life example would be better, especially if there is spacing to respect.

-
Sorry. I made a mistake. The bounty was accidentally given to Ian Thompson. – kiss my armpit Apr 26 '13 at 20:06