tags:

views:

109

answers:

1

Hello:

I'm trying to get something like this:

---------------------------------
|  Hello world  |     Again     |
---------------------------------
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
---------------------------------

So I wrote:

\begin{tabular}{l|l|l}
\multicolumn{4}{c}{Población total en millones}
\multicolumn{4}{c}{Porcentaje de población rural}\\
\hline
1975 & 2001 & 2003 & 2015 & 1975 & 2001 & 2003 & 2015\\
\hline
10,3 & 15,4 & 16 & 17,9 & 21,6 & 14 & 13 & 9,8
\end{tabular}

But it gives me this error:

! Misplaced \omit. \multispan ->\omit \@multispan

What can I do?

Edit

Also, how can I get a border between the two columns?

Thanks.

+3  A: 

You need to have 8 columns set first, then span to it. :) The spanned columns should also be separated by the & alignment operator.

\begin{tabular}{l|l|l|l|l|l|l|l}
  \multicolumn{4}{c}{Poblaci\'{o}n total en millones} &
  \multicolumn{4}{c}{Porcentaje de poblaci\'{o}n rural}\\
  \hline
  1975 & 2001 & 2003 & 2015 & 1975 & 2001 & 2003 & 2015\\
  \hline
  10,3 & 15,4 & 16 & 17,9 & 21,6 & 14 & 13 & 9,8
\end{tabular}

To get the line in between the columns just modify the specifier:

\begin{tabular}{l|l|l|l|l|l|l|l}
    \multicolumn{4}{c|}{Poblaci\'{o}n total en millones} &
    \multicolumn{4}{|c}{Porcentaje de poblaci\'{o}n rural}\\
    \hline
    1975 & 2001 & 2003 & 2015 & 1975 & 2001 & 2003 & 2015\\
    \hline
    10,3 & 15,4 & 16 & 17,9 & 21,6 & 14 & 13 & 9,8
\end{tabular}

More information on table formatting is over at WikiBooks. :)

sirhc
Thanks :D Now that it works I realized that I need to know how to get a border between the two columns.
Tae
Updated my answer to reflect correct accents (although the syntax highlighting here is messed up) and the border. :)
sirhc
Thank you so much! (I'm using the utf8x and spanish packages to write in Spanish without need to scape some symbols.)
Tae