18

I am using IEEE template for my paper writing. Now i want to insert a table which is 11x12. So it needs to stretch to the two columns format in the IEEE format. I did like this:

\documentclass[conference]{IEEEtran}
\setlength{\extrarowheight}{1pt}
\begin{table}
 \caption{CIFAR-10 Confusion Matrix}
\label{my-label}
\begin{tabular}{|*{12}{p{1.11cm}|}}
\hline
labels     & airplane & automobile & bird & cat & deer & dog & frog & horse & ship & truck & accuracy \\ \hline
airplane   & 915      & 4          & 17   & 19  & 3    & 1   & 0    & 2     & 27   & 12    & 91.50\%  \\ \hline
automobile & 8        & 934        & 3    & 4   & 0    & 0   & 3    & 0     & 10   & 38    & 93.40\%  \\ \hline
bird       & 60       & 1          & 813  & 37  & 19   & 23  & 30   & 10    & 7    & 0     & 81.30\%  \\ \hline
cat        & 18       & 1          & 34   & 746 & 25   & 113 & 37   & 18    & 8    & 0     & 74.60\%  \\ \hline
deer       & 24       & 1          & 38   & 33  & 809  & 19  & 44   & 29    & 2    & 1     & 80.90\%  \\ \hline
dog        & 4        & 0          & 37   & 106 & 23   & 792 & 9    & 26    & 2    & 1     & 79.20\%  \\ \hline
frog       & 2        & 5          & 19   & 35  & 1    & 20  & 912  & 2     & 3    & 1     & 91.20\%  \\ \hline
horse      & 14       & 0          & 26   & 20  & 18   & 28  & 4    & 886   & 3    & 1     & 88.60\%  \\ \hline
ship       & 35       & 10         & 3    & 2   & 0    & 2   & 1    & 0     & 936  & 11    & 93.60\%  \\ \hline
truck      & 23       & 37         & 4    & 10  & 1    & 2   & 2    & 0     & 15   & 906   & 90.60\%  \\ \hline
\end{tabular}
\end{table}

and the output is: enter image description here

The problem is that the caption is not centering between the two columns. How to do that??

How to center the table automatically between the two columns of IEEE format??

3
  • 1
    Try to use `\begin{table*}...\end{table*} -- this should span the full width of the paper, not just the first column
    – user31729
    Apr 20, 2016 at 19:55
  • writing * giving me this error : ! Extra }, or forgotten \endgroup. Apr 20, 2016 at 20:02
  • See the possible answer -- your table is too wide, in my point of view!
    – user31729
    Apr 20, 2016 at 20:09

1 Answer 1

21

You need to use a table* environment instead of a table environment, to allow the tabular-like environment to span the width of both columns or, put differently, the full width of the text block.

In addition, you need to do something to assure that the overall width of the tabular-like environment indeed equals \textwidth. You may do this with either a tabualarx or a tabular* environment. For the table at hand, I would recommend you employ a tabularx environment, as it'll make it straightforward to equal widths to the data columns. I further suggest you define and employ a centered version of the X column type for columns 2 thru 11. Finally, I suggest you use the l column type for the first column and the c column type for the final column. (If you really want to left-align the contents of all cells, use the X column type for columns 2 thru 12.)

Oh, and do try to give your table a more "open" look by, say, getting rid of all vertical lines and most horizontal lines and by generating well-spaced horizontal rules with the help of the booktabs package.

enter image description here

\documentclass[conference]{IEEEtran}
\usepackage{tabularx,booktabs}
% defined centered version of "X" column type:
\newcolumntype{C}{>{\centering\arraybackslash}X} 
\setlength{\extrarowheight}{1pt} % for a bit more open "look"
\usepackage{lipsum} % filler text

\begin{document}

\lipsum[1] % filler text

\begin{table*}
\caption{CIFAR-10 Confusion Matrix}
\label{my-label}
\begin{tabularx}{\textwidth}{@{} l *{10}{C} c @{}}
\toprule
labels  
& airplane & automobile & bird & cat & deer 
& dog & frog & horse & ship & truck & accuracy \\ 
\midrule
airplane   & 915      & 4          & 17   & 19  & 3    & 1   & 0    & 2     & 27   & 12    & 91.50\%  \\ 
automobile & 8        & 934        & 3    & 4   & 0    & 0   & 3    & 0     & 10   & 38    & 93.40\%  \\ 
bird       & 60       & 1          & 813  & 37  & 19   & 23  & 30   & 10    & 7    & 0     & 81.30\%  \\ 
cat        & 18       & 1          & 34   & 746 & 25   & 113 & 37   & 18    & 8    & 0     & 74.60\%  \\ 
deer       & 24       & 1          & 38   & 33  & 809  & 19  & 44   & 29    & 2    & 1     & 80.90\%  \\ 
\addlinespace
dog        & 4        & 0          & 37   & 106 & 23   & 792 & 9    & 26    & 2    & 1     & 79.20\%  \\ 
frog       & 2        & 5          & 19   & 35  & 1    & 20  & 912  & 2     & 3    & 1     & 91.20\%  \\ 
horse      & 14       & 0          & 26   & 20  & 18   & 28  & 4    & 886   & 3    & 1     & 88.60\%  \\ 
ship       & 35       & 10         & 3    & 2   & 0    & 2   & 1    & 0     & 936  & 11    & 93.60\%  \\ 
truck      & 23       & 37         & 4    & 10  & 1    & 2   & 2    & 0     & 15   & 906   & 90.60\%  \\ 
\bottomrule
\end{tabularx}
\end{table*}
\lipsum[2-15] % more filler text
\end{document}
8
  • why \end{table*} line giving me this error: ! Extra }, or forgotten \endgroup. Apr 20, 2016 at 20:25
  • If i omit the * from the table then it prints but it overlaps with the other writings... Apr 20, 2016 at 20:37
  • @setubasak - I don't get an error from the code shown above. If you get an error message about an "extra }", it is most lkely because you have an extra } hanging about somewhere.
    – Mico
    Apr 20, 2016 at 20:38
  • @setubasak - Do you get an error message when you compile the code as it is shown above, or do you get an error message when you try to compile some other code?
    – Mico
    Apr 20, 2016 at 20:39
  • I don't think so because when i omit i write \end{table} it then doesn't show the error but the table overlaps with the other contents Apr 20, 2016 at 20:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .