I wanted to place tables horizontally side by side, so i used subtable to create (3 x 2) structure in this way (this is how one of my pages looks like):
\documentclass[11pt,a4paper]{article}
\usepackage{subcaption}
\begin{document}
\begin{table}
\caption{Caption}
\centering
\begin{subtable}{.5\textwidth}
\centering
\caption{$n=100$ \label{tab:tab_1}}
\begin{tabular}{c|c|c}
\hline
\input{tab_all/tab_1.tex}
\hline
\end{tabular}
\end{subtable}%
\begin{subtable}{.5\textwidth}
\centering
\caption{$n=200$ \label{tab:tab_2}}
\begin{tabular}{c|c|c}
\hline
\input{tab_all/tab_1.tex}
\hline
\end{tabular}
\end{subtable}
\end{table}
\begin{table}
\centering
\begin{subtable}{.5\textwidth}
\centering
\caption{$n=300$ \label{tab:tab_3}}
\begin{tabular}{c|c|c}
\hline
\input{tab_all/tab_1.tex}
\hline
\end{tabular}
\end{subtable}%
\begin{subtable}{.5\textwidth}
\centering
\caption{$n=400$\label{tab:tab_4}}
\begin{tabular}{c|c|c}
\hline
\input{tab_all/tab_1.tex}
\hline
\end{tabular}
\end{subtable}
\end{table}
\begin{table}
\centering
\begin{subtable}{.5\textwidth}
\centering
\caption{$n=500$ \label{tab:tab_5}}
\begin{tabular}{c|c|c}
\hline
\input{tab_all/tab_1.tex}
\hline
\end{tabular}
\end{subtable}%
\begin{subtable}{.5\textwidth}
\centering
\caption{$n=600$\label{tab:tab_6}}
\begin{tabular}{c|c|c}
\hline
\input{tab_all/tab_1.tex}
\hline
\end{tabular}
\end{subtable}
\end{table}
\pagebreak
.... same stucture on the next page
I have these on two pages, so 3 more tables (with 2 subtables each) on next page, which i separated with \pagebreak
. I have two questions:
-
How can i fix the problem of "stretching" tables, i.e. these three rows on each page stretch so that it is evenly distributed over one page which i do not want…
-
How could i put my two pages on one (side by side), i.e, how could i get 4 subtables in one row, with subtitle for each pair?
For example purposes, i input here all the time same tab_1, because all tables are in fact same size, just numbers change… Here is the content of the separate tab_1.tex file which i input(table is small so it is no problem to fit 4 in one row in terms of space..)
& param & error \cr\hline
$\beta$ & 0.005 & 5.1e-04 \cr
$\gamma_1$ & -0.116 & 0.014 \cr
$\omega$ & 1.083 & 1.172 \cr
$\delta$ & -0.265 & 0.071 \cr
\hline
Thanks for help!
Best Answer
To have several tables in a row you only need join all the
tabular
environments, without blank lines between. To obtain equal spaces between the tables, use\hfill
.Im an not sure if you want also equal spaces for tables of diferent columns/sizes (i.e, each table plus padding take always 1/4 of the text width). In that case, one option is use the
tabularx
package for the main (hide) table or enclose each table in aminipage
of.25\textwidth
.