![水平对齐表格 - 重新缩放](https://linux22.com/image/314961/%E6%B0%B4%E5%B9%B3%E5%AF%B9%E9%BD%90%E8%A1%A8%E6%A0%BC%20-%20%E9%87%8D%E6%96%B0%E7%BC%A9%E6%94%BE.png)
我想水平对齐两个表格,必要时重新缩放它们,使它们位于同一行。显然,标题也必须缩放,保持与表格中心对齐。
\documentclass{report}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\begin{tabular}{SSS}
\toprule {Col A} & {Col B} & {Col C} \\
\midrule
1 & 2 & 3000000.000 \\
4 & 5 & 6000000.000 \\
\bottomrule
\end{tabular}
\caption[loftitle]{Title 1}
\end{table}
\begin{table}
\centering
\begin{tabular}{SSS}
\toprule {Col D} & {Col E} & {Col F} \\
\midrule
7 & 8 & 9000000.000 \\
10 & 11 & 12000000.000 \\
\bottomrule
\end{tabular}
\caption[loftitle]{Title 2, longer than the width of the table}
\end{table}
\end{document}
答案1
您说得对,必须调整表格的大小才能使其并排显示。
\documentclass{report}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}
\usepackage{booktabs}
\usepackage{adjustbox}% or graphicx
\begin{document}
\begin{table}
\centering
\resizebox{0.45\textwidth}{!}{\begin{tabular}{SSS}
\toprule {Col A} & {Col B} & {Col C} \\
\midrule
1 & 2 & 3000000.000 \\
4 & 5 & 6000000.000 \\
\bottomrule
\end{tabular}}\hfil
\resizebox{0.45\textwidth}{!}{\begin{tabular}{SSS}
\toprule {Col D} & {Col E} & {Col F} \\
\midrule
7 & 8 & 9000000.000 \\
10 & 11 & 12000000.000 \\
\bottomrule
\end{tabular}}
\begin{minipage}[t]{0.45\textwidth}
\caption[loftitle]{Title 1}
\end{minipage}\hfil
\begin{minipage}[t]{0.45\textwidth}
\caption[loftitle]{Title 2, longer than the width of the table}
\end{minipage}
\end{table}
\end{document}
答案2
\captionbox
提供的解决方案。您可以根据需要caption.sty
调整表格的宽度。{0.49\linewidth}
\documentclass{report}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}
\usepackage{booktabs,tabularx}
\usepackage[showframe]{geometry}
\usepackage[tableposition=above]{caption}
\captionsetup[table]{%
aboveskip=3pt,
belowskip=0pt,
labelfont={scriptsize,bf},
textfont={scriptsize,it},
}
\begin{document}
\listoftables
\begin{table}[!h]
\footnotesize\centering
\captionbox[Short title]{Title 1}{%
\begin{tabularx}{0.49\linewidth}{@{}SXS[table-format = 7.3]@{}}
\toprule {Col A} & {Col B} & {Col C} \\
\midrule
1 & 2 & 3000000.000 \\
4 & 5 & 6000000.000 \\
\bottomrule
\end{tabularx}}%
\hfill
\captionbox[Long title]{Title 2, longer than the width of the table
so that you get a line break}{%
\begin{tabularx}{0.49\linewidth}{@{}SXS[table-format = 8.3]@{}}
\toprule {Col D} & {Col E} & {Col F} \\
\midrule
7 & 8 & 9000000.000 \\
10 & 11 & 12000000.000 \\
\bottomrule
\end{tabularx}}%
\end{table}
\end{document}
答案3
无需减小表格材料的字体大小。只需使用 2 个并排的minipage
字体,并使用包table-format
的选项siunitx
将材料正确居中在每个表格的第三列中。并且,[t]
为两种minipage
环境设置定位指令。
(下图中的水平线只是为了说明文本块的宽度。)
\documentclass{report}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}
\usepackage{booktabs}
\begin{document}
\hrule
\begin{table}
\begin{minipage}[t]{0.48\textwidth}
\centering
\begin{tabular}{@{}SSS[table-format=7.3]}
\toprule {Col A} & {Col B} & {Col C} \\
\midrule
1 & 2 & 3000000.000 \\
4 & 5 & 6000000.000 \\
\bottomrule
\end{tabular}
\caption[loftitle]{Title 1}
\end{minipage}
\hspace*{\fill}
\begin{minipage}[t]{0.48\textwidth}
\centering
\begin{tabular}{@{}SSS[table-format=8.3]}
\toprule {Col D} & {Col E} & {Col F} \\
\midrule
7 & 8 & 9000000.000 \\
10 & 11 & 12000000.000 \\
\bottomrule
\end{tabular}
\caption[loftitle]{Title 2, longer than the width of the table}
\end{minipage}
\end{table}
\end{document}