Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

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.

share|improve this answer
    
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.

share|improve this answer
\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.

share|improve this answer
    
Sorry. I made a mistake. The bounty was accidentally given to Ian Thompson. –  stalking is prohibited Apr 26 '13 at 20:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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