3

I am getting this error and the table is failed to generate.

\documentclass{IEEEtran}
\usepackage{booktabs, makecell, multirow, tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage[figuresright]{rotating}
\setlength{\rotFPtop}{0pt plus 1fil}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\renewcommand\theadgape{}
\usepackage{lipsum}  % for dummy text filler
\begin{document}
\begin{table}
\centering
\caption{The consolidated accuracy of the system}
\label{tab:Precision}
\begin{tabular}{ >{\bfseries}c c c c l }
\toprule
\thead{Risk level} &\thead{Precision} & \thead{Recall} & \thead{f1-score} & \thead{Support}\\
    \midrule
  & High & .95 & .93 & 1.00 & 60\\
    \addlinespace
& Medium & .99 & .92 & .93 & 60\\
    \addlinespace
& Low & .95 & .99 & .96 & 60\\
    \addlinespace
& None & .99 & .95 & 1.00 & 60\\
    \bottomrule
\end{tabular}
\end{table}
\lipsum
\end{document} 

Please help. I have tried with tabularx and L combination also, without any success.

3
  • 2
    There are 5 columns specified for the tabular but for all rows but the first (with \thead) there are 6 columns used, with the first is always empty. IMHO you should remove the starting & in each row.
    – cabohah
    Jun 4 at 8:34
  • 1
    Thank you very much, that solved the problem
    – Bukaida
    Jun 4 at 8:36
  • I've made an (extended) answer from my comment. So you can accept it.
    – cabohah
    Jun 4 at 15:43

1 Answer 1

3

The error indicates, that more columns are used than specified. In your case

\begin{tabular}{ >{\bfseries}c c c c l }

specifies five columns: four c columns and one l column. In the first row:

\thead{Risk level} &\thead{Precision} & \thead{Recall} & \thead{f1-score} & \thead{Support}\\

you are indeed using these five columns. But all other columns like:

  & High & .95 & .93 & 1.00 & 60\\

are using six columns: an empty one before the first & and five columns with contents.

So you either have to specify one more column or remove the empty column in each row but the first. Looking to the contents, IMHO removing the empty column would be best. I would additionally recommend to use S columns of package siunitx for all columns but the first one:

\documentclass{IEEEtran}
\usepackage{booktabs,makecell,siunitx}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\usepackage{lipsum}  % for dummy text filler
\begin{document}
\begin{table}
\centering
\caption{The consolidated accuracy of the system}
\label{tab:Precision}
\begin{tabular}{>{\bfseries}c*4S}
\toprule
\thead{Risk level} & {\thead{Precision}} & {\thead{Recall}} & {\thead{f1-score}} & {\thead{Support}}\\
    \midrule
High & .95 & .93 & 1.00 & 60\\
    \addlinespace
Medium & .99 & .92 & .93 & 60\\
    \addlinespace
Low & .95 & .99 & .96 & 60\\
    \addlinespace
None & .99 & .95 & 1.00 & 60\\
    \bottomrule
\end{tabular}
\end{table}
\lipsum
\end{document} 

enter image description here

For example for the last column it could be useful, to specify the decimals. See the siunitx manual for more information.

You must log in to answer this question.

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