8

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??

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

You need to use a table* environment instead of a table environment, to allow the float to take up the space of both columns.

In addition, you need to do something to reduce the width of the table. I suggest you use a tabularx environment instead of the tabular environment and that you use a centered version of the X column type for columns 2 thru 11. Use an l column type for the first column and a c column type for the final column. (If you really want to left-align all cell contents, use the X column type for columns 2 thru 11.)

Oh, and to try to give your table a more "open" look, say, by 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}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" type
\setlength{\extrarowheight}{1pt}
\usepackage{lipsum}
\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}
  • why \end{table*} line giving me this error: ! Extra }, or forgotten \endgroup. – Setu Kumar Basak Apr 20 '16 at 20:25
  • If i omit the * from the table then it prints but it overlaps with the other writings... – Setu Kumar Basak Apr 20 '16 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 '16 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 '16 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 – Setu Kumar Basak Apr 20 '16 at 20:39

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.