0

I have 2 different kinds of tables:

One has more rows and is shorter More rows

And another with less rows but longer Longer

I have 5 sets of each (total 10 tables). Is there a way to place each set side by side? That is, [shorter,longer] and have a title per set (5 titles in total) in one page?

I'm currently generating the tables one at a time and it's taking a lot of pages (I'll just show 1 set):

\begin{table}[ht]
\centering
\caption{Title 1}
\begin{tabular}{lS[table-format=1.4]ccS[table-format=1.4]}
\toprule
\thead{Parameter} & {\thead{Actual\\ Value}} & \thead{Range} & {\thead{Parameter\\ Found}} \\
\midrule
$\alpha$ & 0.191 & (0.191, 0.191) & 0.191\\
$\beta$ & 0.05 & (0.05, 0.05) & 0.05\\
$\gamma$ & 0.0294 & (0.0294, 0.0294) & 0.0294\\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[ht]
\centering
\caption{Title 1}
\begin{tabular}{lS[table-format=1.4]ccS[table-format=1.4]}
\toprule
\thead{(S,I,D,R) Error NN} & & \thead{(S,I,D,R) Error Learnable Parameters} } \\
\midrule
(0.004, 0.025, 0.003, 0.003) & & (0,0,0,0) \\
\bottomrule
\end{tabular}
\end{table}
7
  • 1
    It may be possible, depending on the actual page size, but it can't be done if each is enclosed in a separate table environment. (That is a "float", and is always treated as a separate object.) Try using just tabular without a blank line between two of them, and see if they fit within the width of the page. If not, would they fit if they were rotated 90 degrees counterclockwise? (You can insert captions later, using the caption package.) Commented Jun 30, 2021 at 23:54
  • So I removed the table parts from both and and blank line in between. Now I just have them one on top of each other, but not side by side. Is there a way to force size such that I can fit the 10 nevertheless?
    – Penguin
    Commented Jul 1, 2021 at 0:02
  • Often, the suggestion is to pack each into a minipage, where you can specify the width (say, .48\textwidth), so that two would fit on a "line" with a minimum space between. But the wider form may be too wide for that, (You'd get "overfull hbox" messages, and maybe overprinting, but if properly specified, they'd appear next to each other. That's why I suggested also considering landscape presentation. Commented Jul 1, 2021 at 0:13
  • (i) you have error in your code fragment, (ii) your table has defined more columns than are used (first table define 5, used 4; second table defined 5, used 2), (iii) page layout of your document is unknow.
    – Zarko
    Commented Jul 1, 2021 at 3:28
  • 1
    For example at second table: begin{tabular}{lS[table-format=1.4]ccS[table-format=1.4]} is defined 5 columns: l, S,c,c and again S, you use only (the first) two. I suggest you to make yourself more familiar with writing of table by reading some introductory text about them, for example en.wikibooks.org/wiki/LaTeX/Tables
    – Zarko
    Commented Jul 1, 2021 at 4:32

1 Answer 1

2

You may be able to fit two such tables side by side, if you use suitable margins and a slightly redesigned second table. Here are two different suggestions:

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{caption}
\usepackage{subcaption} % only used in second example


\begin{document}

\begin{table}[ht]
\centering
\caption{Title 1}
\begin{tabular}[t]{lS[table-format=1.4]ccS[table-format=1.4]}
\toprule
\thead{Param.} & {\thead{Actual\\ Value}} & \thead{Range} & {\thead{Parameter\\ Found}} \\
\midrule
$\alpha$ & 0.191 & (0.191, 0.191) & 0.191\\
$\beta$ & 0.05 & (0.05, 0.05) & 0.05\\
$\gamma$ & 0.0294 & (0.0294, 0.0294) & 0.0294\\
\bottomrule
\end{tabular}
\hfill
\begin{tabular}[t]{lc}
\toprule
& \thead{(S,I,D,R)}\\
\midrule
\thead[l]{Error NN} & (0.004, 0.025, 0.003, 0.003) \\
\thead[l]{Error Learnable\\ Parameters} & (0,0,0,0) \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[ht]
\caption{Title 1}
\begin{subtable}[t]{0.49\linewidth}
\centering
\caption{subcaption left table}
\begin{tabular}[t]{lS[table-format=1.4]ccS[table-format=1.4]}
\toprule
\thead{Param.} & {\thead{Actual\\ Value}} & \thead{Range} & {\thead{Parameter\\ Found}} \\
\midrule
$\alpha$ & 0.191 & (0.191, 0.191) & 0.191\\
$\beta$ & 0.05 & (0.05, 0.05) & 0.05\\
$\gamma$ & 0.0294 & (0.0294, 0.0294) & 0.0294\\
\bottomrule
\end{tabular}
\end{subtable}
\hfill
\begin{subtable}[t]{0.47\linewidth}
\centering
\caption{subcaption right table}
\begin{tabular}[t]{lc}
\toprule
& \thead{(S,I,D,R)}\\
\midrule
\thead[l]{Error NN} & (0.004, 0.025, 0.003, 0.003) \\
\thead[l]{Error Learnable\\ Parameters} & (0,0,0,0) \\
\bottomrule
\end{tabular}
\end{subtable}
\end{table}


\end{document}
5
  • This is great! Is there a way to align the tables though? Looks like the one of the left is lower than the one on the right. I tried to use invisible spacing but I couldn't get it to work
    – Penguin
    Commented Jul 1, 2021 at 13:27
  • What exactly do you mean with "align"? The two tables are not equally tall, but both tables are top aligned with respect to each other.
    – leandriis
    Commented Jul 1, 2021 at 14:01
  • Maybe I'm using the wrong word, apologies. Is there a way to make them the same size? So they will start at the same spot (which they currently are), and end at the same spot (which the left table is lower currently)
    – Penguin
    Commented Jul 1, 2021 at 14:05
  • I think the issue can be fixed with making the title longer on the right (I did it with ` \\ )`, but couldn't get it to work otherwise
    – Penguin
    Commented Jul 1, 2021 at 14:22
  • Okay I solved it using this
    – Penguin
    Commented Jul 1, 2021 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .