我该如何修复我的代码?我的列宽度不一致
\begin{table}[h]
\centering
\begin{tabular}{|c|cc|ccc|}
\hline
& \multicolumn{2}{c|}{Test2: Running application} & \multicolumn{3}{c|}{Test1: Running application} \\ \hline
Group & \multicolumn{1}{c|}{G} & $\chi^2$ & \multicolumn{1}{c|}{water} & \multicolumn{1}{c|}{tea} & soda \\ \hline
1 & \multicolumn{1}{c|}{2} & 0 & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{2} & 1 \\ \hline
2 & \multicolumn{1}{c|}{3} & 1 & \multicolumn{1}{c|}{2} & \multicolumn{1}{c|}{2} & 1 \\ \hline
\end{tabular}
\end{table}
答案1
像这样?
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{|c|*{5}{w{c}{5em}|}}
\hline
& \multicolumn{2}{c|}{Test2: Running application}
& \multicolumn{3}{c|}{Test1: Running application} \\
\hline
Group & G & $\chi^2$ & water & tea & soda \\ \hline
1 & 2 & 0 & 3 & 2 & 1 \\ \hline
2 & 3 & 1 & 2 & 2 & 1 \\ \hline
\end{tabular}
\end{table}
\end{document}
不过,我宁愿重新设计表格:
\documentclass{article}
\usepackage{array, booktabs}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{c *{5}{w{c}{3.2em}} }
\toprule
& \multicolumn{5}{c}{Running application} \\
\cmidrule{2-6}
& \multicolumn{2}{c}{Test 1}
& \multicolumn{3}{c}{Test1} \\
\cmidrule(r){2-3} \cmidrule(l){4-6}
Group & G & $\chi^2$ & water & tea & soda \\
\midrule
1 & 2 & 0 & 3 & 2 & 1 \\
2 & 3 & 1 & 2 & 2 & 1 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}