我正在尝试构建一个非常简单的多索引表,但我无法正确对齐下部索引的列。使用以下代码:
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\begin{document}
\begin{table}[!ht]
\centering
\caption{
{\bf Table caption Nulla mi mi, venenatis sed ipsum varius, volutpat euismod diam.}}
\begin{tabular}{@{}lcccc@{}}
\toprule
& \multicolumn{4}{c}{\textbf{Peptide concentration {[}mg/ml{]}}} \\ \midrule
& \textbf{0.29} & \textbf{0.57} & \textbf{1.15} & \textbf{2.3} \\
\textbf{Difference (VL/NEHC)} & 1.58 & 1.48 & 1.82 & 1.03 \\ \bottomrule
\end{tabular}
%\begin{flushleft} Table notes Phasellus venenatis, tortor nec vestibulum mattis, massa tortor interdum felis, nec pellentesque metus tortor nec nisl. Ut ornare mauris tellus, vel dapibus arcu suscipit sed.
%\end{flushleft}
\label{tab:caption}
\end{table}
\end{document}
我们可以看到我的表格看起来可以接受,但我们可以看到“肽浓度[mg / ml]”下方的列分布不均匀/对齐(我期望它们在“肽浓度[mg / ml]”下均匀分布。
我怎样才能将“肽浓度 [mg/ml]”下的这四列均匀分布?
谢谢
答案1
您可以使用makecell
将表头分成两行, siunitx
以便数字对齐和threeparttable
表格注释。我添加了caption
一个合适的间距,使标题和表格之间有:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{booktabs, threeparttable, makecell, caption}
\usepackage{siunitx}
\usepackage{etoolbox}
\robustify\bfseries
\author{Bruno Hinckel}
\begin{document}
\begin{threeparttable}[!ht]
\centering
\sisetup{table-format=1.2, table-number-alignment=center, detect-weight, ,detect-inline-weight=math}
\captionsetup{font=bf}
\caption{
{Table caption Nulla mi mi, venenatis sed ipsum varius, volutpat euismod diam.}}
\label{tab:caption}
\begin{tabular}{@{}l*{4}{S}@{}}
\toprule
& \multicolumn{4}{>{\bfseries}c}{\makecell{Peptide concentration \\[-0.5ex] [mg/ml]}} \\
\midrule
& \bfseries 0.29 & \bfseries 0.57 & \bfseries 1.15 & \bfseries 2.3 \\
\textbf{Difference (VL/NEHC)} & 1.58 & 1.48 & 1.82 & 1.03 \\ \bottomrule
\end{tabular}
\footnotesize\smallskip
\begin{tablenotes}[flushleft] \item[]\emph{Table notes}. Phasellus venenatis, tortor nec vestibulum mattis, massa tortor interdum felis, nec pellentesque metus tortor nec nisl. Ut ornare mauris tellus, vel dapibus arcu suscipit sed.
\end{tablenotes}
\end{threeparttable}
\end{document}