1

I am trying to put two tables side by side in two column format. But I am getting the error

! Missing number, treated as zero. l l.460 \end{tabular*} }

unfortunately it does not give me a clue on what is wrong. Can anyone help me to fix the code below

\begin{table*}
    \setlength{\tabcolsep}{2.5pt}
    \parbox{0.5\textwidth}{
        \centering
        \caption{Data1}
        \label{tab:res1}
        \begin{tabular*}{l*{6}{c}}
            \hline \\ 
            Baseline &   SMC &  RMC  &  PMF  &  MOD  &  SCA  & RSR  \\
            \hline \\ 
            M1     & 0.641 & 0.772 & 0.333 & 0.314 & 0.305 & 0.356 \\
            M2      & 0.301 & 0.372 & 0.853 & 0.814 & 0.805 & 0.846 \\
            \hline
        \end{tabular*}   }
    \hfill
    \parbox{0.5\textwidth}{
    \centering
    \caption{Data 2}
    \label{tab:res2}
    \begin{tabular*}{*{6}{c}}
        \hline \\ 
          SMC  &  RMC  &  PMF  &  MOD  &  SCA  &  RSR \\
        \hline \\ %[-1.55ex]
         0.131 & 0.272 & 0.663 & 0.634 & 0.635 & 0.736 \\
         0.311 & 0.362 & 0.853 & 0.564 & 0.555 & 0.866 \\
        \hline
    \end{tabular*}   }
\end{table*}
  • 1
    as error said, you forgot to define width of tabular*, i.e. you should wrote \begin{tabular*}{\linewidth}{*{6}{c}} . – Zarko Apr 10 at 12:54
  • @Zarko tabular* without change of \extracolsep doesn't make a lot of sense. So maybe tabular* was only a mistake (because of using table*) and should be replaced by tabular. – Schweinebacke Apr 10 at 13:04
2

your problem is solved by comments, however i would wrote your table on the following way:

\documentclass[twocolumn]{article}

\usepackage{booktabs, tabularx}
\usepackage[skip=1ex]{caption}
\usepackage{siunitx}

\usepackage{lipsum}

\begin{document}
    \begin{table*}
    \setlength\tabcolsep{5pt}
\begin{tabularx}{\linewidth}{@{}*{2}{>{\centering\arraybackslash}X}@{}}
    \caption{Data1}
    \label{tab:res1}
\begin{tabular}{l*{6}{c}}
    \toprule
Baseline &   SMC &  RMC  &  PMF  &  MOD  &  SCA  & RSR  \\
    \midrule
M1      & 0.641 & 0.772 & 0.333 & 0.314 & 0.305 & 0.356 \\
M2      & 0.301 & 0.372 & 0.853 & 0.814 & 0.805 & 0.846 \\
    \bottomrule
\end{tabular}
    &
    \caption{Data 2}
    \label{tab:res2}
\begin{tabular}{*{6}{c}}
    \toprule
SMC     &  RMC  &  PMF  &  MOD  &  SCA  &  RSR \\
    \midrule
0.131   & 0.272 & 0.663 & 0.634 & 0.635 & 0.736 \\
0.311   & 0.362 & 0.853 & 0.564 & 0.555 & 0.866 \\
    \bottomrule
\end{tabular}
    \end{tabularx}
\end{table*}

\begin{table*}
    \sisetup{table-format=1.3}
    \setlength\tabcolsep{5pt}
\begin{tabularx}{\linewidth}{@{}*{2}{>{\centering\arraybackslash}X}@{}}
    \caption{Data1}
    \label{tab:res1}
\begin{tabular}{l*{6}{S}}
    \toprule
Baseline & {SMC}& {RMC} & {PMF} & {MOD} & {SCA} & {RSR}  \\
    \midrule
M1      & 0.641 & 0.772 & 0.333 & 0.314 & 0.305 & 0.356 \\
M2      & 0.301 & 0.372 & 0.853 & 0.814 & 0.805 & 0.846 \\
    \bottomrule
\end{tabular}
    &
    \caption{Data 2}
    \label{tab:res2}
\begin{tabular}{*{6}{S}}
    \toprule
{SMC}   & {RMC} & {PMF} & {MOD} & {SCA} & {RSR} \\
    \midrule
0.131   & 0.272 & 0.663 & 0.634 & 0.635 & 0.736 \\
0.311   & 0.362 & 0.853 & 0.564 & 0.555 & 0.866 \\
    \bottomrule
\end{tabular}
    \end{tabularx}
\end{table*}
\end{document}

enter image description here

second example is with use of the S columns from siunitx package which align numbers at decimal points. since all numbers in table have the same number of digits, tables not differ. however, it may become handy if you have for example numbers with teo digit integer part. than you need to change S column format for example to table-format=2.3 (where 2 is number of integer digits and 3 number of decimals).

  • +1 But for number columns I would suggest to use siunitx. And you should add package caption for correct the vertical distance between \caption above the tabulars. – Schweinebacke Apr 10 at 13:05
  • @Schweinebacke, you are right. i thought that use siunitx at numbers with equal number of digits is somehow overkill :-)i will correct this asap. – Zarko Apr 10 at 13:08

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.