# How to align text corresponds to text within the above line?

My attempt was to use tabular:

\begin{tabular}{cccc}
Let & $M_1$ recognize $A_1$, where $M_1 = (Q_1, \Sigma, \delta_1, q_1, F_1)$, & \\
& $M_2$ recognize $A_2$, where $M_1 = (Q_2, \Sigma, \delta_2, q_2, F_2)$. &
\end{tabular}


However, there are several spaces between Let and M_1, how could I get rid of these spaces? Furthermore, is this a standard way to align text? If I want to be the most flexible, i.e. editing on the fly, which approach should I use?

-

## 1 Answer

There are many ways of doing this, and it depends on your preference, or even how big of a structure you are working with. For example, still using tabular, you could consider using

\begin{tabular}{*{3}{@{}l@{\ }}}
Let & $M_1$ recognize $A_1$, & where $M_1=(Q_1,\Sigma,\delta_1,q_1,F_1)$, \\
& $M_2$ recognize $A_2$, & where $M_1=(Q_2,\Sigma,\delta_2,q_2,F_2)$.
\end{tabular}


This creates 3 identical, left-aligned columns (via *{3}{..l..}), where each column has the formatting @{}l@{\ }. This formatting adds a regular space {\ } between columns, and remove the column separation at the beginning of each column (via @{}).

Alternatively you could use boxes (and other structures) to align text components. Here's an example:

\usepackage{calc}%
...
Let $M_1$ recognize $A_1$, where $M_1=(Q_1,\Sigma,\delta_1,q_1,F_1)$, \\
\phantom{Let} $M_2$ recognize \makebox[\widthof{$A_1$}][c]{$A_2$}, where $M_1=(Q_2,\Sigma,\delta_2,q_2,F_2)$.


Although somewhat superfluous, I hope it demonstrates the principle. You can use

\phantom{<stuff>}


to typeset a box exactly the size of <stuff>, without actually typesetting <stuff> itself. Also, using the calc package, you can define boxes of specific width using \widthof{<stuff>} in conjunction with

\makebox[<width>][<horizontal alignment>]{<stuff>}


I'm sure there are other (perhaps more elegant) ways as well.

-
Many thanks for a very detailed solution ;). – Chan Jul 29 '11 at 5:03