如何調整下表中具有例如值的儲存格的垂直對齊方式\{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}