1

I would like to align horizontally two tables, if necessary rescaling them, to put them on the same line. Obviously even the caption must be scaled, remaining aligned with the center of the table.

\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}
  • If they should be aligned, both shouldn't float, should they? – user31729 Jul 10 '15 at 12:52
  • I removed [htp] from both, it was a remnant of the first version. Btw, I guess I can aling horizontally tables even with that addition... – Pippothedog Jul 10 '15 at 13:53
  • You need to put both tabulars into one table (note, one table can also have two captions, but to put them side by side you will need two minipages). – John Kormylo Jul 10 '15 at 17:57
3

You were right about having to resize the tabulars to fit side by side.

tabulars

\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}
  • Perhaps consider using \begin{tabular}[t]... – Werner Jul 10 '15 at 18:21
  • @Werner - Or rescale both to the same factor. There are lots of options. – John Kormylo Jul 10 '15 at 18:23
2

A solution with \captionbox provided by caption.sty. You can resize the width of tables with {0.49\linewidth} acc. to your needs.

enter image description here

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

There's no need to reduce the font size of the tabular material. Just use 2 side-by-side minipages and use the table-format option of the siunitx package to properly center the material in the third column of each table. And, se the [t] positioning directive for both minipage environments.

(The horizontal line in the image below is there just to illustrate the width of the text block.)

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.