[Tex/LaTex] Creating complex tables with multicolumn on different lines on latex

multicolumnmultirowtables

Can someone help me creating this table, I can't figure out how \multicolumn work.
I can get to the first two rows of the table but no further. Please help.

Thanks
enter image description here

Best Answer

With a tabular environment, you need to specify a column for each column in the most populated row. Then, where necessary, you can combine multiple columns together using the \multicolumn command.

The tabular should end up looking like this, with a total of 18 columns:

\documentclass[landscape]{article}
\usepackage[landscape]{geometry}
\begin{document}

\begin{tabular}{|*{18}{c|}}  % repeats {c|} 18 times
\hline
\multicolumn{9}{|c}{k-means clustering} & \multicolumn{9}{|c|}{Fuzzy c-means clustering} \\ \hline
\multicolumn{3}{|c}{50 clusters} & \multicolumn{3}{|c}{60 clusters} & \multicolumn{3}{|c}{70 clusters} & 
\multicolumn{3}{|c}{50 clusters} & \multicolumn{3}{|c}{60 clusters} & \multicolumn{3}{|c|}{70 clusters} \\ \hline 
CJ & HT & SVD &CJ & HT & SVD &CJ & HT & SVD &CJ & HT & SVD &CJ & HT & SVD &CJ & HT & SVD \\ \hline
 & & & & & & & & & & & & & & & & &  \\ \hline
\end{tabular}

\end{document}

tabular

Edit:

To use this in (one example of) a typical two-column environment, you would want to use the \begin{table*} environment, which allows the table to float across the two columns. Note that it will necessarily have to be place on the next page from where you call it, so you might have to make the call to the table earlier in the code than where you want to actually refer to it. This example uses the IEEEtran class to illustrate:

\documentclass[]{IEEEtran}

\usepackage{lipsum} % Dummy Text

\begin{document}

\title{Title}
\maketitle

\section{A Section}
\lipsum

\begin{table*}
\caption{The Caption}
\centering
\begin{tabular}{|*{18}{c|}}
\hline
\multicolumn{9}{|c}{k-means clustering} & \multicolumn{9}{|c|}{Fuzzy c-means clustering} \\ \hline
\multicolumn{3}{|c}{50 clusters} & \multicolumn{3}{|c}{60 clusters} & \multicolumn{3}{|c}{70 clusters} & 
\multicolumn{3}{|c}{50 clusters} & \multicolumn{3}{|c}{60 clusters} & \multicolumn{3}{|c|}{70 clusters} \\ \hline 
CJ & HT & SVD &CJ & HT & SVD &CJ & HT & SVD &CJ & HT & SVD &CJ & HT & SVD &CJ & HT & SVD \\ \hline
 & & & & & & & & & & & & & & & & &  \\ \hline
\end{tabular}
\end{table*}

\section{A Second Section}
\lipsum

\end{document}

It appears as:

page1 page2

Related Question