如何调整下表中具有以下值的单元格的垂直对齐方式\{0.91,0.15\}
:
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{table}[h]
\begin{tabular}{c C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule[1.5pt]
\multirow{2}{*}{days} & \multicolumn{4}{c}{Time in \{Min,Sec\}} \\ \cmidrule[1.5pt](){2-5}
& D & M & A & N \\ \hline
6 & \{5,15\} & & & \\ \hline
6 & \{0.91,0.15\} & & & \\ \hline
6 & \{99,0.5\} & & \{77,22\} & \\ \hline
6 & & & \{0.31,0.15\} & \\ \hline
\end{tabular}
\end{table}
答案1
间距问题似乎适用于表格中的所有行,因此我建议您设置\arraystretch
为1.2
加宽行间距。您可以通过以下方式执行此操作
\renewcommand{\arraystretch}{1.2}
将此命令放入table
环境中将使其成为该环境的本地命令。
如果这是一次性的,那么你可以插入一个零宽度和适当的高度和深度的规则,通过将条目写入以下内容来强制将线条分开
\vrule width 0pt height 12pt depth 5pt \{0.91,0.15\}
例如。
以下是\arraystretch
版本:
\documentclass{article}
\usepackage{multirow,array,booktabs}
\begin{document}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{table}[h]\renewcommand{\arraystretch}{1.2}
\begin{tabular}{c C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule[1.5pt]
\multirow{2}{*}{days} & \multicolumn{4}{c}{Time in \{Min,Sec\}} \\ \cmidrule[1.5pt](){2-5}
& D & M & A & N \\ \hline
6 & \{5,15\} & & & \\ \hline
6 & \{0.91,0.15\} & & & \\ \hline
6 & \{99,0.5\} & & \{77,22\} & \\ \hline
6 & & & \{0.31,0.15\} & \\ \hline
\end{tabular}
\end{table}
\end{document}
答案2
使用booktabs
规则,而不是\hline
;但是,最好避免太多规则;我将介绍表格的两种实现。
\documentclass{article}
\usepackage{array,booktabs}
\begin{document}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{table}[htp]
\begin{tabular}{c C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule
days & \multicolumn{4}{c}{Time in \{Min,\,Sec\}} \\
\cmidrule(lr){2-5}
& D & M & A & N \\
\midrule
6 & \{5,\,15\} & & & \\
6 & \{0.91,\,0.15\} & & & \\
6 & \{99,\,0.5\} & & \{77,\,22\} & \\
6 & & & \{0.31,\,0.15\} & \\
\bottomrule
\end{tabular}
\bigskip
\begin{tabular}{c C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule
days & \multicolumn{4}{c}{Time in \{Min,\,Sec\}} \\
\cmidrule(lr){2-5}
& D & M & A & N \\
\midrule
6 & \{5,\,15\} & & & \\
\midrule
6 & \{0.91,\,0.15\} & & & \\
\midrule
6 & \{99,\,0.5\} & & \{77,\,22\} & \\
\midrule
6 & & & \{0.31,\,0.15\} & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}