# How to align some lines under tabular?

I am using tabular, and I would like to realize something like that:

word1     word2     word3
word4     longerword5
word6     word7     word8


So word1,2,3,4,6,7,8 are well aligned, and I do not want longerword5 to be taken into account for spacing in other rows. Could anyone tell me how to do that?

-
Either change longerword5 to \multicolumn{2}{l}{longerword5} to make it span over two columns ({2}), left aligned ({l}) or write it as \rlap{longerword5} so that its width is ignored. – Martin Scharrer May 20 '11 at 17:11
thank you...... – SoftTimur May 20 '11 at 17:19
@Martin: \rlap is a macro for the cognoscenti; a more orthodox LaTeX is \makebox[0pt][l]{longerword5}. – egreg May 20 '11 at 18:04

Do you know the command \multicolumn. The command is defined by latex itself. So you don't need any packages.

The syntax of the command is:

\multicolumn{n}{<justification>}{<contents>}


n is the numbers of columns. The <justification> can be every known one like, r-l-c-p-m.

A small example:

\documentclass{article}

\begin{document}
\begin{tabular}{|lll|}\hline
word in column 1 & word in column 2 & word in column 3 \\
\hline
\multicolumn{3}{|c|}{words over column 1 to 3}\\
\hline
\end{tabular}
\end{document}


How you can see the vertical rules have to set separately by multicolumn.

-
Maybe you could turn this into a slightly more helpful answer. – Alan Munn May 20 '11 at 17:05
thanks all..... – SoftTimur May 20 '11 at 17:20
@Alan: I think a command like this doesn't need any explanation. In this case google is very useful. – Marco Daniel May 20 '11 at 17:53
depending on one's level of expertise, many things on this site don't need any explanation. But one of the purposes of the site is to become a repository for accurate knowledge (that's part of why answers are votable.) There is a lot of lousy information about LaTeX to be found via google, (even though in this case one might find good information easily.) So why not spend the extra minute or so providing an example to make your answer more helpful to others than have this debate with me? – Alan Munn May 20 '11 at 18:10
@Alan: Ok you are right. – Marco Daniel May 20 '11 at 18:18

Either change longerword5 to \multicolumn{2}{l}{longerword5} to make it span over two columns ({2}), left aligned ({l}) or write it as \rlap{longerword5} so that its width is ignored.

As egreg pointed out \rlap{longerword5} (a TeX macro) is equivalent to the LaTeX macro \makebox[0pt][l]{longerword5}. I personally don't think \rlap (lap to the right) is to complicated to be understood by beginners. Instead \makebox[0pt][l] seems to be more complicated.

-