经过几个小时的谷歌搜索和测试大量的软件包后,我成功地制作了一个双列模式的表格,如下所示:
使用以下代码:
\documentclass[5p,times]{elsarticle}
\usepackage{amsmath,amssymb}
\usepackage{multirow, graphicx}
\usepackage{float}
\usepackage{lipsum}
\usepackage{dblfloatfix}
\usepackage{array}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage[referable]{threeparttablex}
\usepackage{caption}
\captionsetup[table]{labelfont=bf,labelsep=newline}
\captionsetup{labelsep=space,justification=justified,singlelinecheck=off}
\usepackage[colorlinks=true, linkcolor=blue]{hyperref}
\begin{document}
\lipsum
\begin{table*}[!b]
\begin{threeparttable}
\caption{This is the table's caption.}
\label{t:table1}
\vspace{-.7em}
\begin{tabular}{p{0.228\linewidth}p{0.228\linewidth}p{0.228\linewidth}p{0.228\linewidth}}
\toprule
\text{Parameters}\tnotex{tn:a} & Calculated\tnotex{tn:b} & Calculated\tnotex{tn:c} & Calculated\tnotex{tn:d} \\
\midrule
A & 1234 & 1234 & 1234 \\
B & -123 & -12 & -12 \\
C & -123 & -123 & -123 \\
D & 123 & 123 & 123 \\
E & -123 & -123 & -123 \\
F & -123 & 12 & -123 \\
G & 123 & 123 & 123 \\
H & 1234 & 1234 & 1234 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item [a] \label{tn:a} Parameters' Values reported in Ref a.
\item [b] \label{tn:b} Parameters' Values reported in Ref b.
\item [c] \label{tn:c} Parameters' Values reported in Ref c.
\item [d] \label{tn:d} Parameters' Values reported in Ref d.
\end{tablenotes}
\end{threeparttable}
\end{table*}
\lipsum
\lipsum
\end{document}
如果上面的代码中只存在包(如果可能的话),我必须进行哪些更改才能获得具有与此相同的间距和数据对齐的表:
先感谢您。
答案1
您应该使用siunitx
和tabular*
:
\documentclass[5p,times]{elsarticle}
\usepackage{amsmath,amssymb}
\usepackage{multirow, graphicx}
\usepackage{float}
\usepackage{dblfloatfix}
\usepackage{array}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage[referable]{threeparttablex}
\usepackage{siunitx}
\usepackage{lipsum}
\usepackage{caption}
\captionsetup[table]{labelfont=bf,labelsep=newline}
\captionsetup{labelsep=space,justification=justified,singlelinecheck=off}
\usepackage[colorlinks=true, linkcolor=blue]{hyperref}
\begin{document}
\lipsum
\begin{table*}[!bp]
\begin{threeparttable}
\caption{This is the table's caption.}
\label{t:table1}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
l
S[table-format=-3.0]
S[table-format=-3.0]
S[table-format=-3.0]
@{}
}
\toprule
Parameters\tnotex{tn:a} & {Calculated\tnotex{tn:b}} &
{Calculated\tnotex{tn:c}} & {Calculated\tnotex{tn:d}} \\
\midrule
A & 1234 & 1234 & 1234 \\
B & -123 & -12 & -12 \\
C & -123 & -123 & -123 \\
D & 123 & 123 & 123 \\
E & -123 & -123 & -123 \\
F & -123 & 12 & -123 \\
G & 123 & 123 & 123 \\
H & 1234 & 1234 & 1234 \\
\bottomrule
\end{tabular*}
\begin{tablenotes}
\item [a] \label{tn:a} Parameters' Values reported in Ref a.
\item [b] \label{tn:b} Parameters' Values reported in Ref b.
\item [c] \label{tn:c} Parameters' Values reported in Ref c.
\item [d] \label{tn:d} Parameters' Values reported in Ref d.
\end{tablenotes}
\end{threeparttable}
\end{table*}
\lipsum
\lipsum
\end{document}
需要注意的几点:
- 列标题
S
应该用括号括起来 - 的值
table-format
应该反映整数部分和小数部分的位数;这里的数字在整数部分最多有四位数字,但减号比数字宽,因此-3.0
适合数据
如果要在表格两侧添加填充,请将序言更改为
\begin{tabular*}{\textwidth}{
l
@{\hspace{2\tabcolsep}\extracolsep{\fill}}
S[table-format=-3.0]
S[table-format=-3.0]
S[table-format=-3.0]
}