我使用 Latex 绘制了一个表格,我尝试了很多方法,删除和添加,仍然出现以下错误
我的 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
错误来自\multicolumn{2}{}{\makecell{\textbf{95\%}...
。您不能在那里使用空的第二个参数。此外,只有tabularx
当您至少有一X
列时, 才真正有意义。这里有两个版本,一个带有X
列,另一个是纯tabular
。我还增加了 的第一个参数以\multirow
摆脱这些overfull \vbox
消息。
\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}