使“ID”在下表标题中垂直居中的最佳方法是什么?
另外,有没有人有什么建议或推荐可以让这张桌子更美观?谢谢!
\documentclass{article}
\usepackage[abbreviations=true,per-mode=symbol]{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{table}
\caption{Specific Acid Added to Samples}
\label{Acid_Added}
\centering
\begin{tabular}{ >{\bfseries}c S[table-format=2.2] S[table-format=2.2] S[table-format=1.2] }
\toprule
ID & {Specific Acid} & {Spread} & {Specific Acid} \\
& {Weight [\si{\mg}]} & {Weight [\si{\g}]} & {Conc [\si{\mg\per\g}]} \\
\midrule
1 &0.20 &19.96 &0.01\\
2 &0.40 &20.00 &0.02\\
3 &1.00 &19.98 &0.05\\
4 &2.00 &20.00 &0.10\\
5 &4.00 &20.00 &0.20\\
6 &10.00 &20.00 &0.50\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
ID
这是我使用包\thead
中的命令垂直居中的表格的两个版本 makecell
:
\documentclass{article}
\usepackage[abbreviations=true,per-mode=symbol]{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\begin{document}
\begin{table}
\caption{Specific Acid Added to Samples}
\label{Acid_Added}
\centering
\begin{tabular}{ >{\bfseries}c S[table-format=2.2] S[table-format=2.2] S[table-format=1.2] }
\toprule
\thead{ID} & {\thead{Specific Acid\\ Weight [\si{\mg}]}} & {\thead{Spread\\ Weight [\si{\g}]}} & {\thead{Specific Acid\\Conc [\si{\mg\per\g}]}} \\
\midrule
1 &0.20 &19.96 &0.01\\
2 &0.40 &20.00 &0.02\\
3 &1.00 &19.98 &0.05\\
4 &2.00 &20.00 &0.10\\
5 &4.00 &20.00 &0.20\\
6 &10.00 &20.00 &0.50\\
\bottomrule
\end{tabular}
\end{table}
\begin{table}
\renewcommand{\theadfont}{\normalsize}
\caption{Specific Acid Added to Samples}
\label{Acid_Added}
\centering
\begin{tabular}{ >{\bfseries}c S[table-format=2.2] S[table-format=2.2] S[table-format=1.2] }
\toprule
\thead{ID} & {\thead{Specific Acid\\ Weight [\si{\mg}]}} & {\thead{Spread\\ Weight [\si{\g}]}} & {\thead{Specific Acid\\Conc [\si{\mg\per\g}]}} \\
\midrule
1 &0.20 &19.96 &0.01\\
2 &0.40 &20.00 &0.02\\
3 &1.00 &19.98 &0.05\\
4 &2.00 &20.00 &0.10\\
5 &4.00 &20.00 &0.20\\
6 &10.00 &20.00 &0.50\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
就我个人而言,我更喜欢不使用粗体 ID 的表格,并且我还会使用包caption
来控制标题和规则之间的间距:
\documentclass{article}
\usepackage[abbreviations=true,per-mode=symbol]{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{caption}
\begin{document}
\begin{table}
\caption{Specific Acid Added to Samples}
\label{Acid_Added}
\centering
\begin{tabular}{c S[table-format=2.2] S[table-format=2.2] S[table-format=1.2] }
\toprule
\thead{ID} & {\thead{Specific Acid\\ Weight [\si{\mg}]}} & {\thead{Spread\\ Weight [\si{\g}]}} & {\thead{Specific Acid\\Conc [\si{\mg\per\g}]}} \\
\midrule
1 &0.20 &19.96 &0.01\\
2 &0.40 &20.00 &0.02\\
3 &1.00 &19.98 &0.05\\
4 &2.00 &20.00 &0.10\\
5 &4.00 &20.00 &0.20\\
6 &10.00 &20.00 &0.50\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
该multirow
包允许您垂直融合单元格。一旦将其加载到您的序言中,您就可以使用命令\multirow{<number of cells to fuse>}{<width>}{<content>}
。请注意,您可以将替换width
为*
以遵守给定的单元格宽度。