tags:

views:

151

answers:

3

Hi

I have a simple alignment question for Latex tables. At the moment it looks as follows:

\begin{center}
  \begin{tabular}{| c | l | l | }
   \hline
    \tt {a} & $a = b + c + d + e + f + g + $ \\ 
        & $    e + f + g + h + i + j$ \\ \hline
    \end{tabular}
\end{center}

The problem is, that the output looks as follows:

a = b + c + ...
e + f + ....

However, I would like to have it looks as

a = b + c + ...
    e + f + ...

Anyone an idea how I could do that in a table?

Thanks, Klaus

+5  A: 

Please use the align environment for multiline equations.


You can add a \phantom{a = } to indicate the should-be-existing spaces.

    & $\phantom{a = }e + f + g + h + i + j$ \\ \hline
KennyTM
Ah, the `\phantom` solution is nice too.
Damien Pollet
+1, right answer. Cf. p7 of ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf, the amsmath style guide. You will need \usepackage{amsmath}
Charles Stewart
+2  A: 

As KennyTM pointed out, you shouldn't typeset multiline equations using tables like this. But if you must do it, you could do it like this:

\begin{center}
  \begin{tabular}{| c | l @{} l | }
   \hline
    \tt {a} & $a =\;$ & $b + c + d + e + f + g + $ \\ 
        & & $e + f + g + h + i + j$ \\ \hline
    \end{tabular}
\end{center}
Hans W
A: 

The usual way is to make an additional column for the a = part; right-aligning it, and removing spacing with the next column for aesthetics:

\begin{tabular}{ c r @{} l } % you have one superfluous l
  \tt {a} & $a =$ & $b + c + d + e + f + g +$ \\ 
          &       & $e + f + g + h + i + j$ \\
\end{tabular}

Maybe you will need an explicit space after the = sign, so that it's properly spaced with the b.

Another solution would be to have a multiline equation in a single cell of the table, but that amounts to the same (you will need an array environment or something similar to wrap the left part).

Damien Pollet