如何使两列表格条目更靠近表格的中心?

如何使两列表格条目更靠近表格的中心?

因此,下面的 latex 代码会创建一个两列表格,将条目放在最左边和最右边。我只想保留整体布局,但将列条目放在靠近表格中心的位置。我该怎么做?

(Revtex4-1)

\documentclass[reprint, superscriptaddress, showpacs, preprintnumbers, amsmath, amssymb, aps, prb]{revtex4-1}
\begin{document}

\preprint{APS/123-QED}

\begin{table}[h]%The best place to locate the table environment is directly after its first reference in text
\caption{\label{tab:table1}%
A table that fits into a single column of a...
}
\begin{ruledtabular}
\begin{tabular}{ l c }
\textrm{Material}&
\textrm{Bond Length}\\
\colrule
2D Aluminum & \(\thicksim\)2.54 \text{\AA}\\
Cycloaluminum helides & 2.643 \text{\AA}, 2.587 \text{\AA}\\
Aluminum tetramers & 2.773 \text{\AA}, 2.767 \text{\AA}\\
\end{tabular}
\end{ruledtabular}
\end{table}

\end{document}

答案1

默认设置ruledtabular是将其扩展以覆盖所有可用的列宽(在我看来,这是错误的做法,因为表格应该是其自然宽度)。

您可以模拟ruledtabular并获得具有其自然宽度的表格:

\documentclass[twocolumn]{revtex4-1}
\usepackage{amssymb}
\usepackage{lipsum}
\begin{document}

\lipsum[2]

\begin{table}[h]%The best place to locate the table environment is directly after its first reference in text
\caption{\label{tab:table1}%
A table that fits into a single column of a...
}
\begin{ruledtabular}
\begin{tabular}{ l c }
\textrm{Material}&
\textrm{Bond Length}\\
\colrule
2D Aluminum & \(\thicksim\)2.54 \text{\AA}\\
Cycloaluminum helides & 2.643 \text{\AA}, 2.587 \text{\AA}\\
Aluminum tetramers & 2.773 \text{\AA}, 2.767 \text{\AA}\\
\end{tabular}
\end{ruledtabular}
\end{table}

\lipsum[2]

\begin{table}[h]%The best place to locate the table environment is directly after its first reference in text
\caption{\label{tab:table2}%
A table that fits into a single column of a...
}
\begin{tabular}{ l @{\qquad} c }
\toprule
\textrm{Material}&
\textrm{Bond Length}\\
\colrule
2D Aluminum & \(\thicksim\)2.54 \text{\AA}\\
Cycloaluminum helides & 2.643 \text{\AA}, 2.587 \text{\AA}\\
Aluminum tetramers & 2.773 \text{\AA}, 2.767 \text{\AA}\\
\botrule
\end{tabular}
\end{table}

\lipsum

\end{document}

在此处输入图片描述

如果您想使用ruledtabular,您可以添加一些空间(在两侧):

\lipsum[2]

\begin{table}[h]%The best place to locate the table environment is directly after its first reference in text
\caption{\label{tab:table1}%
A table that fits into a single column of a...
}
\begin{ruledtabular}
\begin{tabular}{@{\hspace{3em}} l c @{\hspace{3em}}}
\textrm{Material}&
\textrm{Bond Length}\\
\colrule
2D Aluminum & \(\thicksim\)2.54 \text{\AA}\\
Cycloaluminum helides & 2.643 \text{\AA}, 2.587 \text{\AA}\\
Aluminum tetramers & 2.773 \text{\AA}, 2.767 \text{\AA}\\
\end{tabular}
\end{ruledtabular}
\end{table}

\lipsum[2]

在此处输入图片描述

答案2

除了考虑如何缩小表格材料的宽度(如果我理解您的目的,同时保持全列宽度的外部表格)之外,您还应该考虑改善数字和“埃”符号之间的间距。为了实现改进,我建议您加载包siunitx并使用其\SI宏来排版数字/单位组合。

为了在行和第一个完整数据行之间获得足够的间距\colrule,请考虑在数据行中插入“顶部支柱”,如下面的代码所示。

哦,数据列的“缩进”可以通过在“真实”列的最左边和最右边定义“虚拟”(即未使用的)列来实现。

在此处输入图片描述

\documentclass[reprint, superscriptaddress, showpacs, preprintnumbers, amsmath, amssymb, aps, prb]{revtex4-1}
\usepackage{siunitx}
\newcommand\Tstrut{\rule{0pt}{2.6ex}}  % "top" strut
\begin{document}

\preprint{APS/123-QED}

\begin{table}
\caption{A table that fits into a single column of a \dots}
\label{tab:table1}
\begin{ruledtabular}
 % First and final "c" columns are dummy (empty) columns
\begin{tabular}{ c l c c }
& Material & Bond Length\\
\colrule
& 2D Aluminum & $\approx$ \SI{2.54}{\angstrom}\Tstrut\\
& Cycloaluminum helides & \SI{2.643}{\angstrom}, \SI{2.587}{\angstrom}\\
& Aluminum tetramers & \SI{2.773}{\angstrom}, \SI{2.767}{\angstrom}\\
\end{tabular}
\end{ruledtabular}
\end{table}

\end{document}

相关内容