我正在尝试使用以下 TeX 代码将两个“三部分表格”并排放在一个文档中:
\documentclass[10pt, a4paper]{article}
\usepackage[a4paper, total={7in, 10in}]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{threeparttable}
\begin{document}
\begin{table}[!htb]
\setlength\tabcolsep{3pt}
\footnotesize
\renewcommand{\arraystretch}{1.25}
\begin{threeparttable}
\begin{minipage}{0.5\linewidth}
\centering
\begin{tabular}{@{}
r S[table-format=-2.3] S[table-format=-2.3]
@{\hspace{12pt}} !{\vrule width 0.2pt} @{\hspace{12pt}}
r S[table-format=-2.3] S[table-format=-2.3]
@{}}
\toprule
\multicolumn{1}{c}{$r_h$} & $\omega_{Re}$ & \multicolumn{1}{c}{$\omega_{Im}$} &
\multicolumn{1}{c}{$r_h$} & $\omega_{Re}$ & $\omega_{Im}$ \\
\midrule[0.08cm]
\multicolumn{6}{c}{\textbf{\textbf{$a=0.01 $ }}}\\
~ 1 & 2.799 & -2.687 & 5 & 9.492 & -13.332 \\
10 & 18.629 & -26.649 & 25 & 46.303 & -66.596 \\
50 & 92.516 &-133.201 & 100 & 184.982 &-266.401 \\
125 & 231.100 &-332.833 & 200 & 368.978&-531.432 \\
225 & 415.166 & -597.962 & 300 & 555.017 & -799.401 \\
\multicolumn{6}{c}{\textbf{$ a=0.1 $}} \\
~ 1 &2.936 &-2.745 & 5 & 9.689 &-13.398 \\
10 & 18.830 &-26.715 & 25 &46.505 &-66.671 \\
50 & 92.718 & -133.266 & 100 & 185.178 & -266.459 \\
125 & 231.411 &-333.055 & 200 & 370.115 &-532.844 \\
225 & 416.349 &-599.439 & 300 & 555.056 &-799.231 \\
\multicolumn{6}{c}{\textbf{\textbf{$a = 0.2$}}} \\
~ 1 &3.091 &-2.809 & 5 & 9.906 &-13.470 \\
10 & 19.052 &-26.788 & 25 & 46.729 &-66.744 \\
50 & 92.942 &-133.340 & 100 & 185.402 &-266.532 \\
125 &231.636 &-333.128 & 200 & 370.339 &-532.917 \\
225 &416.574 &-599.513 & 300 &555.280 &-799.303 \\
\bottomrule
\end{tabular}
\end{minipage}
\hfill
\begin{minipage}{0.5\linewidth}
\centering
\begin{tabular}{@{}
r S[table-format=-2.3] S[table-format=-2.3]
@{\hspace{12pt}} !{\vrule width 0.2pt} @{\hspace{12pt}}
r S[table-format=-2.3] S[table-format=-2.3]
@{}}
\toprule
\multicolumn{1}{c}{$r_h$} & $\omega_{Re}$ & \multicolumn{1}{c}{$\omega_{Im}$} &
\multicolumn{1}{c}{$r_h$} & $\omega_{Re}$ & $\omega_{Im}$ \\
\midrule[0.08cm]
\multicolumn{6}{c}{\textbf{\textbf{$a=0.01 $ }}}\\
~ 1 &2.813 & -2.677 & 5 & 9.493 &-13.332 \\
10 &18.629 & -26.649 & 25 &46.303 &-66.605 \\
50 &92.516 &-133.201 & 100 & 184.982 & -266.401 \\
125 &231.100 &-332.833 & 200 & 368.978 &-531.432 \\
225 &415.166 &-597.962 & 300 & 555.017 &-799.303 \\
\multicolumn{6}{c}{\textbf{$ a=0.1 $}} \\
~ 1 &2.949 &-2.736 & 5 & 9.690 & -13.398 \\
10 & 18.830 & -26.715 & 25 & 46.505 & -66.671\\
50 &92.718 & -133.266 & 100 & 185.178 & -266.459 \\
125 & 231.411 & -333.055 & 200 & 370.115&-532.844 \\
225 & 416.349 & -599.439 & 300 &555.056 &-799.401\\
\multicolumn{6}{c}{\textbf{\textbf{$a = 0.2$}}} \\
~ 1 &3.102 & -2.801 & 5 & 9.907 &-13.471 \\
10 & 19.052 & -26.788 & 25 &46.729 &-66.744 \\
50 &92.943 & -133.339 & 100 & 185.403 & -266.532 \\
125 & 231.636 &-333.129 & 200 & 370.339 &-532.917 \\
225 &416.574 &-599.513 & 300 & 555.280 &-799.303 \\
\bottomrule
\end{tabular}
\end{minipage}
\end{threeparttable}
\end{table}
\end{document}
但我无法获得预期的结果。任何这方面的帮助都将非常有益!
答案1
您的代码存在几个问题。无特定顺序:
您似乎根本没有使用
threeparttable
包的机制。环境的三个正式部分threeparttable
是 (a)tabular
类似环境、(b)\caption
指令和 (c)tablenotes
环境。由于没有\caption
指令和tablenotes
环境,并且tabular
环境被封装在minipage
环境中,因此无形的对于单一threeparttable
环境,它基本上什么都不做。直接忽略它就行了。环境
minipage
似乎也没有做任何有用的事情。我也会忽略它们。嵌套
\textbf
指令——如\textbf{\textbf{...}}
——是没有意义的。指令的参数
\textbf
应该是文本模式材料。因此,\textbf{$a=0.01$}
保证不会做任何有用的事情。您是否想写$\mathbf{a=0.01}$
,等等?列
S[table-format=-2.3]
格式规范似乎都是错误的。为什么不使用S[table-format=3.3]
或S[table-format=-3.3]
?我会删除垂直规则。它们是不需要的。
该
\footnotesize
指令也不需要。很多材料似乎都需要数学模式。我建议您使用
array
环境tabular
并删除大量$
符号,以进一步减少代码混乱。最后但同样重要的一点是,不要在两个
tabular
/array
环境之间留下空行。
\documentclass[10pt]{article}
\usepackage[a4paper, total={7in, 10in}]{geometry}
\usepackage{booktabs}
\usepackage{siunitx} % for 'S' column type
% handy shortcut macros:
\newcommand\omegaRe{\omega_{\mkern1mu\mathrm{Re}}}
\newcommand\omegaIm{\omega_{\mkern1mu\mathrm{Im}}}
\begin{document}
\begin{table}[!htb]
\setlength\arraycolsep{4pt} % default: 5pt
\renewcommand{\arraystretch}{1.25}
$\begin{array}[t]{@{}
r S[table-format=3.3] S[table-format=-3.3]
@{\hspace{25pt}}
r S[table-format=3.3] S[table-format=-3.3]
@{}}
\toprule
r_h & {\omegaRe} & {\omegaIm} & r_h & {\omegaRe} & {\omegaIm} \\
\midrule
\multicolumn{6}{c}{\mathbf{a=0.01}}\\
1 & 2.799 & -2.687 & 5 & 9.492 & -13.332 \\
10 & 18.629 & -26.649 & 25 & 46.303 & -66.596 \\
50 & 92.516 &-133.201 & 100 & 184.982 &-266.401 \\
125& 231.100 &-332.833 & 200 & 368.978 &-531.432 \\
225& 415.166 &-597.962 & 300 & 555.017 &-799.401 \\
\addlinespace
\multicolumn{6}{c}{\mathbf{a=0.1}} \\
1 & 2.936 & -2.745 & 5 & 9.689 & -13.398 \\
10 & 18.830 & -26.715 & 25 & 46.505 & -66.671 \\
50 & 92.718 &-133.266 & 100 & 185.178 &-266.459 \\
125 &231.411 &-333.055 & 200 & 370.115 &-532.844 \\
225 &416.349 &-599.439 & 300 & 555.056 &-799.231 \\
\addlinespace
\multicolumn{6}{c}{\mathbf{a=0.2}} \\
1 & 3.091 & -2.809 & 5 & 9.906 & -13.470 \\
10 & 19.052 & -26.788 & 25 & 46.729 & -66.744 \\
50 & 92.942 &-133.340 & 100 & 185.402 &-266.532 \\
125 &231.636 &-333.128 & 200 & 370.339 &-532.917 \\
225 &416.574 &-599.513 & 300 & 555.280 &-799.303 \\
\bottomrule
\end{array}$
% don't leave a blank line
\hfill
% don't leave a blank line
$\begin{array}[t]{@{}
r S[table-format=3.3] S[table-format=-3.3]
@{\hspace{25pt}}
r S[table-format=3.3] S[table-format=-3.3]
@{}}
\toprule
r_h & {\omegaRe} & {\omegaIm} & r_h & {\omegaRe} & {\omegaIm} \\
\midrule
\multicolumn{6}{c}{\mathbf{a=0.01}}\\
1 & 2.813 & -2.677 & 5 & 9.493 & -13.332 \\
10 & 18.629 & -26.649 & 25 & 46.303 & -66.605 \\
50 & 92.516 &-133.201 & 100 & 184.982 &-266.401 \\
125 &231.100 &-332.833 & 200 & 368.978 &-531.432 \\
225 &415.166 &-597.962 & 300 & 555.017 &-799.303 \\
\addlinespace
\multicolumn{6}{c}{\mathbf{a=0.1}} \\
1 & 2.949 & -2.736 & 5 & 9.690 & -13.398 \\
10 & 18.830 & -26.715 & 25 & 46.505 & -66.671 \\
50 & 92.718 &-133.266 & 100 & 185.178 &-266.459 \\
125 &231.411 &-333.055 & 200 & 370.115 &-532.844 \\
225 &416.349 &-599.439 & 300 & 555.056 &-799.401 \\
\addlinespace
\multicolumn{6}{c}{\mathbf{a=0.2}} \\
1 & 3.102 & -2.801 & 5 & 9.907 & -13.471 \\
10 & 19.052 & -26.788 & 25 & 46.729 & -66.744 \\
50 & 92.943 &-133.339 & 100 & 185.403 &-266.532 \\
125 &231.636 &-333.129 & 200 & 370.339 &-532.917 \\
225 &416.574 &-599.513 & 300 & 555.280 &-799.303 \\
\bottomrule
\end{array}$
\end{table}
\end{document}
答案2
空行是段落的结尾。如果希望表格并排,则不应结束一个段落并开始一个新段落。删除空行:
\documentclass[10pt, a4paper]{article}
\usepackage[a4paper, total={7in, 10in}]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{threeparttable}
\begin{document}
\begin{table}[!htb]
\setlength\tabcolsep{3pt}
\footnotesize
\renewcommand{\arraystretch}{1.25}
\begin{threeparttable}
\begin{minipage}{0.5\linewidth}
\centering
\begin{tabular}{@{}
r S[table-format=-2.3] S[table-format=-2.3]
@{\hspace{12pt}} !{\vrule width 0.2pt} @{\hspace{12pt}}
r S[table-format=-2.3] S[table-format=-2.3]
@{}}
\toprule
\multicolumn{1}{c}{$r_h$} & $\omega_{Re}$ & \multicolumn{1}{c}{$\omega_{Im}$} &
\multicolumn{1}{c}{$r_h$} & $\omega_{Re}$ & $\omega_{Im}$ \\
\midrule[0.08cm]
\multicolumn{6}{c}{\textbf{\textbf{$a=0.01 $ }}}\\
~ 1 & 2.799 & -2.687 & 5 & 9.492 & -13.332 \\
10 & 18.629 & -26.649 & 25 & 46.303 & -66.596 \\
50 & 92.516 &-133.201 & 100 & 184.982 &-266.401 \\
125 & 231.100 &-332.833 & 200 & 368.978&-531.432 \\
225 & 415.166 & -597.962 & 300 & 555.017 & -799.401 \\
\multicolumn{6}{c}{\textbf{$ a=0.1 $}} \\
~ 1 &2.936 &-2.745 & 5 & 9.689 &-13.398 \\
10 & 18.830 &-26.715 & 25 &46.505 &-66.671 \\
50 & 92.718 & -133.266 & 100 & 185.178 & -266.459 \\
125 & 231.411 &-333.055 & 200 & 370.115 &-532.844 \\
225 & 416.349 &-599.439 & 300 & 555.056 &-799.231 \\
\multicolumn{6}{c}{\textbf{\textbf{$a = 0.2$}}} \\
~ 1 &3.091 &-2.809 & 5 & 9.906 &-13.470 \\
10 & 19.052 &-26.788 & 25 & 46.729 &-66.744 \\
50 & 92.942 &-133.340 & 100 & 185.402 &-266.532 \\
125 &231.636 &-333.128 & 200 & 370.339 &-532.917 \\
225 &416.574 &-599.513 & 300 &555.280 &-799.303 \\
\bottomrule
\end{tabular}
\end{minipage}%
\hfill
\begin{minipage}{0.5\linewidth}
\centering
\begin{tabular}{@{}
r S[table-format=-2.3] S[table-format=-2.3]
@{\hspace{12pt}} !{\vrule width 0.2pt} @{\hspace{12pt}}
r S[table-format=-2.3] S[table-format=-2.3]
@{}}
\toprule
\multicolumn{1}{c}{$r_h$} & $\omega_{Re}$ & \multicolumn{1}{c}{$\omega_{Im}$} &
\multicolumn{1}{c}{$r_h$} & $\omega_{Re}$ & $\omega_{Im}$ \\
\midrule[0.08cm]
\multicolumn{6}{c}{\textbf{\textbf{$a=0.01 $ }}}\\
~ 1 &2.813 & -2.677 & 5 & 9.493 &-13.332 \\
10 &18.629 & -26.649 & 25 &46.303 &-66.605 \\
50 &92.516 &-133.201 & 100 & 184.982 & -266.401 \\
125 &231.100 &-332.833 & 200 & 368.978 &-531.432 \\
225 &415.166 &-597.962 & 300 & 555.017 &-799.303 \\
\multicolumn{6}{c}{\textbf{$ a=0.1 $}} \\
~ 1 &2.949 &-2.736 & 5 & 9.690 & -13.398 \\
10 & 18.830 & -26.715 & 25 & 46.505 & -66.671\\
50 &92.718 & -133.266 & 100 & 185.178 & -266.459 \\
125 & 231.411 & -333.055 & 200 & 370.115&-532.844 \\
225 & 416.349 & -599.439 & 300 &555.056 &-799.401\\
\multicolumn{6}{c}{\textbf{\textbf{$a = 0.2$}}} \\
~ 1 &3.102 & -2.801 & 5 & 9.907 &-13.471 \\
10 & 19.052 & -26.788 & 25 &46.729 &-66.744 \\
50 &92.943 & -133.339 & 100 & 185.403 & -266.532 \\
125 & 231.636 &-333.129 & 200 & 370.339 &-532.917 \\
225 &416.574 &-599.513 & 300 & 555.280 &-799.303 \\
\bottomrule
\end{tabular}
\end{minipage}
\end{threeparttable}
\end{table}
\end{document}
结果是:
答案3
我看不出这threeparttable
对这项工作有什么帮助。
我只需使用tabular*
适当的尺寸即可在两个表之间留出一些水平空间;设置\tabcolsep
为零会让 TeX 完成计算空间的工作。
我还修改了列规范以符合实际数据。如果您希望以粗体打印案例,请使用\boldmath
,而不是\textbf
,这对数学没有任何作用。
\documentclass[10pt, a4paper]{article}
\usepackage[a4paper, total={7in, 10in}]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}[!htb]
%\footnotesize
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{0.48\textwidth}{
@{\extracolsep{\fill}}
S[table-format=3.0]
S[table-format=3.3]
S[table-format=-3.3]
@{\qquad}
S[table-format=3.0]
S[table-format=-3.3]
S[table-format=-3.3]
}
\toprule
{$r_h$} & {$\omega_{\mathrm{Re}}$} & {$\omega_{\mathrm{Im}}$} &
{$r_h$} & {$\omega_{\mathrm{Re}}$} & {$\omega_{\mathrm{Im}}$} \\
\midrule
\multicolumn{6}{c}{\boldmath$a=0.01$}\\
1 & 2.799 & -2.687 & 5 & 9.492 & -13.332 \\
10 & 18.629 & -26.649 & 25 & 46.303 & -66.596 \\
50 & 92.516 & -133.201 & 100 & 184.982 & -266.401 \\
125 & 231.100 & -332.833 & 200 & 368.978 & -531.432 \\
225 & 415.166 & -597.962 & 300 & 555.017 & -799.401 \\
\addlinespace
\multicolumn{6}{c}{\boldmath$a=0.1$} \\
1 & 2.936 & -2.745 & 5 & 9.689 & -13.398 \\
10 & 18.830 & -26.715 & 25 & 46.505 & -66.671 \\
50 & 92.718 & -133.266 & 100 & 185.178 & -266.459 \\
125 & 231.411 & -333.055 & 200 & 370.115 & -532.844 \\
225 & 416.349 & -599.439 & 300 & 555.056 & -799.231 \\
\addlinespace
\multicolumn{6}{c}{\boldmath$a = 0.2$} \\
1 & 3.091 & -2.809 & 5 & 9.906 & -13.470 \\
10 & 19.052 & -26.788 & 25 & 46.729 & -66.744 \\
50 & 92.942 & -133.340 & 100 & 185.402 & -266.532 \\
125 & 231.636 & -333.128 & 200 & 370.339 & -532.917 \\
225 & 416.574 & -599.513 & 300 & 555.280 & -799.303 \\
\bottomrule
\end{tabular*}\hfill
\begin{tabular*}{0.48\textwidth}{
@{\extracolsep{\fill}}
S[table-format=3.0]
S[table-format=3.3]
S[table-format=-3.3]
@{\qquad}
S[table-format=3.0]
S[table-format=-3.3]
S[table-format=-3.3]
}
\toprule
{$r_h$} & {$\omega_{\mathrm{Re}}$} & {$\omega_{\mathrm{Im}}$} &
{$r_h$} & {$\omega_{\mathrm{Re}}$} & {$\omega_{\mathrm{Im}}$} \\
\midrule
\multicolumn{6}{c}{\boldmath$a=0.01$} \\
1 & 2.813 & -2.677 & 5 & 9.493 & -13.332 \\
10 & 18.629 & -26.649 & 25 & 46.303 & -66.605 \\
50 & 92.516 & -133.201 & 100 & 184.982 & -266.401 \\
125 & 231.100 & -332.833 & 200 & 368.978 & -531.432 \\
225 & 415.166 & -597.962 & 300 & 555.017 & -799.303 \\
\addlinespace
\multicolumn{6}{c}{\boldmath$a=0.1$} \\
1 & 2.949 & -2.736 & 5 & 9.690 & -13.398 \\
10 & 18.830 & -26.715 & 25 & 46.505 & -66.671 \\
50 & 92.718 & -133.266 & 100 & 185.178 & -266.459 \\
125 & 231.411 & -333.055 & 200 & 370.115 & -532.844 \\
225 & 416.349 & -599.439 & 300 & 555.056 & -799.401 \\
\addlinespace
\multicolumn{6}{c}{\boldmath$a = 0.2$} \\
1 & 3.102 & -2.801 & 5 & 9.907 & -13.471 \\
10 & 19.052 & -26.788 & 25 & 46.729 & -66.744 \\
50 & 92.943 & -133.339 & 100 & 185.403 & -266.532 \\
125 & 231.636 & -333.129 & 200 & 370.339 & -532.917 \\
225 & 416.574 & -599.513 & 300 & 555.280 & -799.303 \\
\bottomrule
\end{tabular*}
\caption{Here is a caption for the side-by-side tables}
\end{table}
\end{document}
如果您想添加子字幕:
\documentclass[10pt, a4paper]{article}
\usepackage[a4paper, total={7in, 10in}]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{subcaption}
\begin{document}
\begin{table}[!htb]
\setlength{\tabcolsep}{0pt}
\begin{subtable}{0.48\textwidth}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
S[table-format=3.0]
S[table-format=3.3]
S[table-format=-3.3]
@{\qquad}
S[table-format=3.0]
S[table-format=-3.3]
S[table-format=-3.3]
}
\toprule
{$r_h$} & {$\omega_{\mathrm{Re}}$} & {$\omega_{\mathrm{Im}}$} &
{$r_h$} & {$\omega_{\mathrm{Re}}$} & {$\omega_{\mathrm{Im}}$} \\
\midrule
\multicolumn{6}{c}{\boldmath$a=0.01$}\\
1 & 2.799 & -2.687 & 5 & 9.492 & -13.332 \\
10 & 18.629 & -26.649 & 25 & 46.303 & -66.596 \\
50 & 92.516 & -133.201 & 100 & 184.982 & -266.401 \\
125 & 231.100 & -332.833 & 200 & 368.978 & -531.432 \\
225 & 415.166 & -597.962 & 300 & 555.017 & -799.401 \\
\addlinespace
\multicolumn{6}{c}{\boldmath$a=0.1$} \\
1 & 2.936 & -2.745 & 5 & 9.689 & -13.398 \\
10 & 18.830 & -26.715 & 25 & 46.505 & -66.671 \\
50 & 92.718 & -133.266 & 100 & 185.178 & -266.459 \\
125 & 231.411 & -333.055 & 200 & 370.115 & -532.844 \\
225 & 416.349 & -599.439 & 300 & 555.056 & -799.231 \\
\addlinespace
\multicolumn{6}{c}{\boldmath$a = 0.2$} \\
1 & 3.091 & -2.809 & 5 & 9.906 & -13.470 \\
10 & 19.052 & -26.788 & 25 & 46.729 & -66.744 \\
50 & 92.942 & -133.340 & 100 & 185.402 & -266.532 \\
125 & 231.636 & -333.128 & 200 & 370.339 & -532.917 \\
225 & 416.574 & -599.513 & 300 & 555.280 & -799.303 \\
\bottomrule
\end{tabular*}
\caption{Subcaption}
\end{subtable}\hfill
\begin{subtable}{0.48\textwidth}
\begin{tabular*}{\textwidth}
@{\extracolsep{\fill}}
S[table-format=3.0]
S[table-format=3.3]
S[table-format=-3.3]
@{\qquad}
S[table-format=3.0]
S[table-format=-3.3]
S[table-format=-3.3]
}
\toprule
{$r_h$} & {$\omega_{\mathrm{Re}}$} & {$\omega_{\mathrm{Im}}$} &
{$r_h$} & {$\omega_{\mathrm{Re}}$} & {$\omega_{\mathrm{Im}}$} \\
\midrule
\multicolumn{6}{c}{\boldmath$a=0.01$} \\
1 & 2.813 & -2.677 & 5 & 9.493 & -13.332 \\
10 & 18.629 & -26.649 & 25 & 46.303 & -66.605 \\
50 & 92.516 & -133.201 & 100 & 184.982 & -266.401 \\
125 & 231.100 & -332.833 & 200 & 368.978 & -531.432 \\
225 & 415.166 & -597.962 & 300 & 555.017 & -799.303 \\
\addlinespace
\multicolumn{6}{c}{\boldmath$a=0.1$} \\
1 & 2.949 & -2.736 & 5 & 9.690 & -13.398 \\
10 & 18.830 & -26.715 & 25 & 46.505 & -66.671 \\
50 & 92.718 & -133.266 & 100 & 185.178 & -266.459 \\
125 & 231.411 & -333.055 & 200 & 370.115 & -532.844 \\
225 & 416.349 & -599.439 & 300 & 555.056 & -799.401 \\
\addlinespace
\multicolumn{6}{c}{\boldmath$a = 0.2$} \\
1 & 3.102 & -2.801 & 5 & 9.907 & -13.471 \\
10 & 19.052 & -26.788 & 25 & 46.729 & -66.744 \\
50 & 92.943 & -133.339 & 100 & 185.403 & -266.532 \\
125 & 231.636 & -333.129 & 200 & 370.339 & -532.917 \\
225 & 416.574 & -599.513 & 300 & 555.280 & -799.303 \\
\bottomrule
\end{tabular*}
\caption{Subcaption}
\end{subtable}
\caption{Here is a caption for the side-by-side tables}
\end{table}
\end{document}