我在 TabularX 中制作了一个列宽表,并想将其置于页面顶部,但还没有找到如何操作的答案——有办法吗?
\begin{center}
\footnotesize
\begin{tabularx} {\columnwidth} {
| >{\centering\arraybackslash}X
| >{\centering\arraybackslash}X
| >{\centering\arraybackslash}X
| >{\centering\arraybackslash}X |}
\hline
\makecell{Planet\\} & \makecell{Mass\\(M\textsubscript{s})} & \makecell{SMA\\(AU)} & \makecell{TA\\(\textdegree)} \\
\hline
b & 0.003 & 70 & 153 \\
\hline
c & 0.004 & 38.9 & 48 \\
\hline
d & 0.005 & 25.6 & 292 \\
\hline
e & 0.008 & 14.4 & 327 \\
\hline
\end{tabularx}
\captionof{table}{Parameters calculated using figs 2 and 3.}
\label{Table 1}
\end{center}
答案1
要强制 LaTeX 将材料排版tabularx
在列的顶部,请将材料放在环境中table
,而不是center
环境中。请注意,由于环境的宽度tabularx
设置为\columnwidth
,因此\centering
不需要明确的指令。
还请考虑@David Carlisle 的建议,将三个数据列中的数字对齐到其(显式或隐式)小数点标记上。并且,请尝试通过删除所有垂直规则并使用更少但间距适当的水平规则来使表格具有更开放和吸引人的“外观”。以下屏幕截图显示了这两项建议的应用。
\documentclass[twocolumn]{article}
\usepackage{tabularx,makecell,dcolumn,booktabs,lipsum}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{d}[1]{D..{#1}}
% handy shortcut macros:
\newcommand\mC[1]{\multicolumn{1}{C}{#1}} % without vertical rules
\newcommand\mD[1]{\multicolumn{1}{C|}{#1}} % with vertical rules
\begin{document}
\lipsum[1] % filler text
\begin{table}[t]
%\footnotesize % not needed
\begin{tabularx}{\columnwidth}{
| *{4}{C|} }
\hline
\makecell{Planet\\} &
\makecell{Mass\\(M\textsubscript{s})} &
\makecell{SMA\\(AU)} &
\makecell{TA\\(\textdegree)} \\
\hline
b & 0.003 & 70 & 153 \\
\hline
c & 0.004 & 38.9 & 48 \\
\hline
d & 0.005 & 25.6 & 292 \\
\hline
e & 0.008 & 14.4 & 327 \\
\hline
\end{tabularx}
\caption{OP's original version}
\label{table:parameters1}
\bigskip
\begin{tabularx}{\columnwidth}{
| >{\centering}X | d{1.3} | d{2.1} | d{3.0} |}
\hline
Planet &
\mD{\makecell{Mass\\(M\textsubscript{s})}} &
\mD{\makecell{SMA\\(AU)}} &
\mD{\makecell{TA\\(\textdegree)}} \\
\hline
b & 0.003 & 70 & 153 \\
\hline
c & 0.004 & 38.9 & 48 \\
\hline
d & 0.005 & 25.6 & 292 \\
\hline
e & 0.008 & 14.4 & 327 \\
\hline
\end{tabularx}
\caption{Numbers aligned on decimal markers}
\label{table:parameters2}
\bigskip
\begin{tabularx}{\columnwidth}{
@{} >{\centering}X d{1.3} d{2.1} d{3.0} @{}}
\toprule
Planet &
\mC{\makecell{Mass\\(M\textsubscript{s})}} &
\mC{\makecell{SMA\\(AU)}} &
\mC{\makecell{TA\\(\textdegree)}} \\
\midrule
b & 0.003 & 70 & 153 \\
c & 0.004 & 38.9 & 48 \\
d & 0.005 & 25.6 & 292 \\
e & 0.008 & 14.4 & 327 \\
\bottomrule
\end{tabularx}
\caption{Numbers aligned on decimal markers, no vertical rules, fewer but well-spaced horizontal rules}
\label{table:parameters3}
\end{table}
\lipsum[2-4] % more filler text
\end{document}