我试过这段代码:
\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{No.} & \multicolumn{2}{c|}{Initial concentration(M)} & \multirow{2}{*}{\Delta t_1} & \multirow{2}{*}{\Delta t_2} & \multirow{2}{*}{\Delta t_3} & \multirow{2}{*}{\Delta t_{ave}} \\ \cline{2-3}
& \ch{Na2S2O3} & \ch{H2SO4} & & & & \\ \hline
%%%%%Row 1%%%%%%%%%%
1 & & & & & & \\ \hline
%%%%%Row 2%%%%%%%%%%
2 & & & & & & \\ \hline
%%%%%Row 3%%%%%%%%%%
3 & & & & & & \\ \hline
\end{tabular}
\end{table}
显然,您可以看到 H2SO4 单元比 Na2S2O3 更宽,那么我怎样才能使这些单元相等呢?
答案1
如果您希望 (a) 第 2 列和第 3 列的宽度相等,并且 (b) 第 2 列和第 3 列的总宽度刚好足以容纳字符串Initial concentration ($M$)
,我建议您按照下面显示的第一个表进行操作。代码首先测量字符串的宽度Initial concentration ($M$)
,然后根据此信息计算第 2 列和第 3 列的可用宽度。该方法采用包w
提供的列类型array
。
不过,我鼓励您考虑采用完全不同的布局,一种具有更开放和更吸引人的“外观”的布局。这可以通过删除所有垂直线并使用更少但间距适当的水平线,借助宏的帮助,以简单的方式完成。书签包。在此过程中,您还可以为第 4 列至第 7 列的标题提供更多结构,并确保它们具有相同的宽度。请参阅第二张表以了解这些想法的实现。
\documentclass{article}
\usepackage{mhchem,multirow,calc,array,amsmath,booktabs}
\newlength\mylenA
\newlength\mylenB
\newlength\mylenC
\begin{document}
\begin{table}[th]
% determine target width of combined cols 2 and 3:
\settowidth\mylenA{Initial concentration ($M$)}
% determine usable width of cols 2 and 3:
\setlength\mylenB{(\mylenA-2\tabcolsep)/2}
\centering
\begin{tabular}{| c | *{2}{wc{\mylenB}|} c | c | c | c |}
\hline
\multirow{2}{*}{No.} &
\multicolumn{2}{c|}{Initial concentration ($M$)} &
\multirow{2}{*}{$\Delta t_1$} &
\multirow{2}{*}{$\Delta t_2$} &
\multirow{2}{*}{$\Delta t_3$} &
\multirow{2}{*}{$\Delta t_{\mathrm{ave}}$} \\
\cline{2-3}
& \ce{Na2S2O3} & \ce{H2SO4} & & & & \\ \hline
1 & & & & & & \\ \hline
2 & & & & & & \\ \hline
3 & & & & & & \\ \hline
\end{tabular}
\end{table}
%% same table, but with well-spaced horizontal rules and no vertical rules:
\begin{table}[h]
% determine target usable width of combined cols 2 and 3:
\settowidth\mylenA{Initial concentration ($M$)}
% determine usable width of cols 2 and 3:
\setlength\mylenB{(\mylenA-2\tabcolsep)/2}
% set target width of cols 4 thru 7:
\settowidth\mylenC{avg.}
\centering
\begin{tabular}{@{} l *{2}{wc{\mylenB}} *{4}{wc{\mylenC}} @{}}
\toprule
No. &
\multicolumn{2}{c}{Initial concentration ($M$)} &
\multicolumn{4}{c@{}}{$\Delta t$} \\
\cmidrule(lr){2-3} \cmidrule(l){4-7}
& \ce{Na2S2O3} & \ce{H2SO4} & 1 & 2 & 3 & avg. \\ \midrule
1 & & & & & & \\ \addlinespace
2 & & & & & & \\ \addlinespace
3 & & & & & & \\ \bottomrule
\end{tabular}
\end{table}
\end{document}