1

I draw a table using Latex, i tried many methods, delete and add, still have the error below

My MWE:

\documentclass[12pt,oneside]{book}

\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{makecell, multirow, tabularx}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{hhline, boldline}
\usepackage{seqsplit, caption} %for table spacing to second row
\usepackage{booktabs, ragged2e} % Use booktabs rules and get rid of vertical rules, ragged2e to ragged text
\usepackage{siunitx} %for table spacing to second row
\usepackage{threeparttable} %to add footnote below table
\usepackage{tabulary}
\usepackage{graphicx}

\begin{document}

\begin{table}[h!]
\centering

\begin{tabularx}{\textwidth}{c>{\raggedright\arraybackslash}ccccccccc}
        \toprule
% &  \small {\textbf{Mean (\%)}} 
& \multirow{3.5}{*}{\makecell{\textbf{Mean}\\ \textbf{(\%)}}} 
& \multirow{3.5}{*}{\makecell{\textbf{Std.}\\ \textbf{Devia-} \\ \textbf{tion} \\ \textbf{(\%)}}} 
& \multirow{3.5}{*}{\makecell{\textbf{Std.}\\ \textbf{Error} \\ \textbf{Mean}  \\ \textbf{(\%)}}} 
% & \multicolumn{2}{>{\centering\arraybackslash}p{8em}}{\textbf{95\% Confidence Interval of the Difference (\%)}}
& \multicolumn{2}{}{\makecell{\textbf{95\%}\\ \textbf{Confidence} \\ \textbf{Interval}  \\ \textbf{of the}  \\ \textbf{Difference (\%) }   }} 
& \multirow{3.5}{*}{\textbf{t}}
& \multirow{3.5}{*}{\textbf {df}} 
& \multirow{3.5}{*}{\makecell{\textbf{Sig.}\\ \textbf{(2-} \\ \textbf{tailed)} }}  \\
\cmidrule{5-6}  %\cmidrule(lr){3-4}
     & & & & \multicolumn{1}{c}{\textbf{Lower}} &  \multicolumn{1}{c}{\textbf{Upper}} \\
\midrule
    {Pair 1\tnote{a}} & 43.33 & 16.56 & 5.24 & 31.48  &  55.18 & 8.27 & 9 & 0.000\\
    \bottomrule
\end{tabularx}
\end{table}

\end{document}
1
  • 1
    The error is in \multicolumn{2}{}{\makecell{\textbf{95\%}, you need to add a column type, e.g. \multicolumn{2}{c}{\makecell{\textbf{95\%}. Also a tabularx needs at least one X column. – user194703 Nov 21 '19 at 2:49
1

The error comes from \multicolumn{2}{}{\makecell{\textbf{95\%}.... You cannot have an empty second argument there. In addition, tabularx makes only real sense if you have at least one X column. Here are two versions, one with an X column and one plain tabular. I also increased the first argument of \multirow to get rid of the overfull \vbox messages.

\documentclass[12pt,oneside]{book}
\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{makecell, multirow, tabularx}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{hhline, boldline}
\usepackage{seqsplit, caption} %for table spacing to second row
\usepackage{booktabs, ragged2e} % Use booktabs rules and get rid of vertical rules, ragged2e to ragged text
\usepackage{siunitx} %for table spacing to second row
\usepackage{threeparttable} %to add footnote below table

\begin{document}

\begin{table}[h!]
\centering
\begin{tabularx}{0.95\textwidth}{X>{\raggedright\arraybackslash}X*8{c}}
        \toprule
% % &  \small {\textbf{Mean (\%)}} 
& \multirow{4}{*}{\makecell{\textbf{Mean}\\ \textbf{(\%)}}} 
 & \multirow{4}{*}{\makecell{\textbf{Std.}\\ \textbf{Devia-} \\ \textbf{tion} \\ \textbf{(\%)}}} 
 & \multirow{4}{*}{\makecell{\textbf{Std.}\\ \textbf{Error} \\ \textbf{Mean}  \\ \textbf{(\%)}}} 
% % & \multicolumn{2}{>{\centering\arraybackslash}p{8em}}{\textbf{95\% Confidence Interval of the Difference (\%)}}
 & \multicolumn{2}{c}{\makecell{\textbf{95\%}\\ \textbf{Confidence} \\ \textbf{Interval}  \\ \textbf{of the}  \\ \textbf{Difference (\%) }   }} 
 & \multirow{4}{*}{\textbf{t}}
 & \multirow{4}{*}{\textbf {df}} 
 & \multirow{4}{*}{\makecell{\textbf{Sig.}\\ \textbf{(2-} \\ \textbf{tailed)} }}  
\\
 \cmidrule{5-6}  %\cmidrule(lr){3-4}
      & & & & \multicolumn{1}{c}{\textbf{Lower}} &  \multicolumn{1}{c}{\textbf{Upper}} \\
 \midrule
     {Pair 1\tnote{a}} & 43.33 & 16.56 & 5.24 & 31.48  &  55.18 & 8.27 & 9 & 0.000\\
    \bottomrule
\end{tabularx}
\end{table}

\begin{table}[h!]
\centering
\begin{tabular}{*{10}c}
        \toprule
% % &  \small {\textbf{Mean (\%)}} 
& \multirow{4}{*}{\makecell{\textbf{Mean}\\ \textbf{(\%)}}} 
 & \multirow{4}{*}{\makecell{\textbf{Std.}\\ \textbf{Devia-} \\ \textbf{tion} \\ \textbf{(\%)}}} 
 & \multirow{4}{*}{\makecell{\textbf{Std.}\\ \textbf{Error} \\ \textbf{Mean}  \\ \textbf{(\%)}}} 
% % & \multicolumn{2}{>{\centering\arraybackslash}p{8em}}{\textbf{95\% Confidence Interval of the Difference (\%)}}
 & \multicolumn{2}{c}{\makecell{\textbf{95\%}\\ \textbf{Confidence} \\
 \textbf{Interval}  \\ \textbf{of the}  \\ \textbf{Difference (\%)  }}} 
 & \multirow{4}{*}{\textbf{t}}
 & \multirow{4}{*}{\textbf {df}} 
 & \multirow{4}{*}{\makecell{\textbf{Sig.}\\ \textbf{(2-} \\ \textbf{tailed)} }}  
\\
 \cmidrule{5-6}  %\cmidrule(lr){3-4}
      & & & & \multicolumn{1}{c}{\textbf{Lower}} &  \multicolumn{1}{c}{\textbf{Upper}} \\
 \midrule
     {Pair 1\tnote{a}} & 43.33 & 16.56 & 5.24 & 31.48  &  55.18 & 8.27 & 9 & 0.000\\
    \bottomrule
\end{tabular}
\end{table}

\end{document}

enter image description here

2
  • car Thanks. brilliant! I didn't know that. Just one question, can you explain in simple words for \begin{tabular}{c>{\raggedright\arraybackslash}c*8{>{\centering\arraybackslash}c}} meaning? – aan Nov 21 '19 at 10:55
  • @aan This was just me being stupid. What I should have done is to write *{10}c, which means that there are 10 columns of the type c. In general, *{<n>}{<type>} creates n columns of type type. – user194703 Nov 21 '19 at 13:36

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.