midtiby
midtiby

Reputation: 15116

Latex multicolumn problems

I am trying to build a table in latex where five columns have a common title centered above the columns. But the generated table does not appear as expected. (the common title is left justified instead of centered above the columns)

The code looks like

\documentclass{article}

\begin{document}

\begin{table}
\centering
\begin{tabular}{|l|c|c|c|r|}
\multicolumn{5}{c}{Hydrotalcite} \\
\hline
kalhsdfsa & 1 asdf asf asfa &7as dfas fasdf as0 & 003  \\
kalhsdfsa & 1 asdf asf asfa &7as dfas fasdf as0 & 003  \\
kalhsdfsa & 1 asdf asf asfa &7as dfas fasdf as0 & 003 
\end{tabular}
\caption{lala}
\label{tabTableRefereaSDasdnce}
\end{table}

\end{document}

And I'm running miktex 2.8 on Windows XP

Upvotes: 3

Views: 4926

Answers (2)

NomeN
NomeN

Reputation: 17603

your multicolumn amount is one too high

change to \multicolumn{4}{c}{Hydrotalcite} \\\hline

(in stead of \multicolumn{5}{c}{Hydrotalcite} \\\hline)

or actually add the fifth column ;-)

Upvotes: 2

Etaoin
Etaoin

Reputation: 8734

You specify five columns in your tabular environment, and you specify that the \multicolumn should span five columns, but no row of the table has more than four entries. Adding a fifth column causes the \multicolumn to work properly.

Upvotes: 2

Related Questions