水平对齐表格 - 重新缩放

水平对齐表格 - 重新缩放

我想水平对齐两个表格,必要时重新缩放它们,使它们位于同一行。显然,标题也必须缩放,保持与表格中心对齐。

\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}

相关内容