2

There are a lot of examples on spanning columns and rows in a table. I tried them to create a table like this but failed!

           +-----------------------------+
           | A  |  B |  C |  D | E  | F  |
 +----+----+-----------------------------+
 | 1  | 2  | 30 | 40 | 50 | 60 | 70 | 80 |
 |    | 3  | 31 | 41 | 51 | 61 | 71 | 81 |
 +----+----+-----------------------------+
 | 4  | 5  | 32 | 42 | 52 | 62 | 72 | 82 |
 |    | 6  | 33 | 43 | 53 | 63 | 73 | 83 |
 +----+----+-----------------------------+

Here is the code I wrote

\begin{table*}
    \centering
    \caption{Prefetchers coverage}
    \label{prefetch-coverage}
    \begin{tabular}{ |c|c|c|c|c|c|c|c|}
        \cline{3-8}
        \\multicolumn{2}{c}{}      &       &   A   &   B   &   C   &    D   &   E   &   F \\ 
        \hline
                                1  &   2   &  30   &  40   &  50   &  60    &  70   &  80   \\
        \cline{2-8}
                                   &   3   &  31   &  41   &  51   &  61    & 71    &  81   \\
        \hline
                                4  &   5   &  32   &  42   &  52   &  62    & 72    &  82   \\ 
        \cline{2-8}
                                   &   6   &  33   &  43   &  53   &  63    & 73    &  83   \\
        \hline
    \end{tabular}
\end{table*}    

The output however is fragmented in the first row. Where did I miss?

4

You have \\multicolumn which is wrong. Then you should have

\multicolumn{2}{c|}{}

in order to print the rule.

Here's the correct code, with also a different way to lay out your table.

\documentclass[twocolumn]{article}
\usepackage{booktabs} % for the second table

\begin{document}
\begin{table*}
\centering
\caption{Prefetchers coverage}
\label{prefetch-coverage}

\medskip

\begin{tabular}{|*{8}{c|}}
\cline{3-8}
\multicolumn{2}{c|}{}     &  A &  B &  C &  D &  E &  F \\ 
\hline
                    1 & 2 & 30 & 40 & 50 & 60 & 70 & 80 \\
\cline{2-8}
                      & 3 & 31 & 41 & 51 & 61 & 71 & 81 \\
\hline
                    4 & 5 & 32 & 42 & 52 & 62 & 72 & 82 \\ 
\cline{2-8}
                      & 6 & 33 & 43 & 53 & 63 & 73 & 83 \\
\hline
\end{tabular}
\end{table*}
\begin{table*}
\centering
\caption{Prefetchers coverage}
\label{prefetch-coverage2}

\medskip

\begin{tabular}{*{8}{c}}
\toprule
  &   &  A &  B &  C &  D &  E &  F \\ 
\midrule
1 & 2 & 30 & 40 & 50 & 60 & 70 & 80 \\
  & 3 & 31 & 41 & 51 & 61 & 71 & 81 \\
\midrule
4 & 5 & 32 & 42 & 52 & 62 & 72 & 82 \\ 
  & 6 & 33 & 43 & 53 & 63 & 73 & 83 \\
\bottomrule
\end{tabular}
\end{table*}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.