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
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityWith 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}
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:
\begin{tabular}{|*{18}{c|}}
for a more compact column definition.
\begin{table*}
environment; it should work with any two-column format, so long as your font sizes don't expand the table so much that it goes outside the given margins.
\multicolumn
for the two first rows.`
to mark your inline code as I did in my edit.