开发者

How to get two \multicolum in a LaTeX table?

I'm trying to get something like this:

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

So I wrote:

开发者_如何学JAVA\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.


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. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜