[Tex/LaTex] table side by side with minipage

horizontal alignmentminipagetables

I can't manage to get two tables side by side in a minipage environment. Any kind suggestion would be highly appreciated!

\documentclass{article}
\usepackage{array}

\begin{document}
\begin{table}[htbp]
\centering
\begin{minipage}{.2\textwidth}
    \begin{tabular}{| m{3cm} | m{4.3cm} | c |} 
 \hline
 number of entity filter (size 1) & number of context filters (size 2, size 3,
 size 4) & Accuracy\\ [2ex] 
 \hline

32  &  32  ,  32  ,  32  &  0.835 \\[0.5ex]
\hline
32  &  64  ,  64  ,  64  &  0.821 \\[0.5ex]
\hline
32  &  128  ,  128  ,  128  &  0.819 \\[0.5ex]
\hline
32  &  256  ,  256  ,  256  &  0.749 \\[0.5ex]
\hline
32  &  512  ,  512  ,  512  &  0.683 \\[0.5ex]
\hline
32  &  1024  ,  1024  ,  1024  &  0.528 \\[0.5ex]
\hline
32  &  2048  ,  2048  ,  2048  &  0.235 \\[0.5ex]
\hline
64  &  32  ,  32  ,  32  &  0.850 \\[0.5ex]
\hline
64  &  64  ,  64  ,  64  &  0.816 \\[0.5ex]
\hline
64  &  128  ,  128  ,  128  &  0.786 \\[0.5ex]
\hline
64  &  256  ,  256  ,  256  &  0.795 \\[0.5ex]
\hline
64  &  512  ,  512  ,  512  &  0.765 \\[0.5ex]
\hline
64  &  1024  ,  1024  ,  1024  &  0.669 \\[0.5ex]
\hline
64  &  2048  ,  2048  ,  2048  &  0.331 \\[0.5ex]
\hline
128  &  32  ,  32  ,  32  &  0.920 \\[0.5ex]
\hline
128  &  64  ,  64  ,  64  &  0.890 \\[0.5ex]
\hline
128  &  128  ,  128  ,  128  &  0.886 \\[0.5ex]
\hline
128  &  256  ,  256  ,  256  &  0.846 \\[0.5ex]
\hline
128  &  512  ,  512  ,  512  &  0.789 \\[0.5ex]
\hline
128  &  1024  ,  1024  ,  1024  &  0.755 \\[0.5ex]
\hline
128  &  2048  ,  2048  ,  2048  &  0.488 \\[0.5ex]
\hline
256  &  32  ,  32  ,  32  &  0.920 \\[0.5ex]
\hline
256  &  64  ,  64  ,  64  &  0.922 \\[0.5ex]
\hline
256  &  128  ,  128  ,  128  &  0.912 \\[0.5ex]
\hline
256  &  256  ,  256  ,  256  &  0.877 \\[0.5ex]
\hline
256  &  512  ,  512  ,  512  &  0.872 \\[0.5ex]
\hline
256  &  1024  ,  1024  ,  1024  &  0.771 \\[0.5ex]
\hline
256  &  2048  ,  2048  ,  2048  &  0.683 \\[0.5ex]
 \hline
 \end{tabular}
\end{minipage}%
\hfill
\begin{minipage}{.2\textwidth}
    \begin{tabular}{| m{3cm} | m{4.3cm} | c |} 
 \hline
 number of entity filter (size 1) & number of context filters (size 2, size 3,
 size4) & Accuracy\\ [2ex] 
 \hline
512  &  32  ,  32  ,  32  &  0.910 \\[0.5ex]
\hline
512  &  64  ,  64  ,  64  &  0.922 \\[0.5ex]
\hline
512  &  128  ,  128  ,  128  &  0.909 \\[0.5ex]
\hline
512  &  256  ,  256  ,  256  &  0.910 \\[0.5ex]
\hline
512  &  512  ,  512  ,  512  &  0.883 \\[0.5ex]
\hline
512  &  1024  ,  1024  ,  1024  &  0.730 \\[0.5ex]
\hline
512  &  2048  ,  2048  ,  2048  &  0.682 \\[0.5ex]
\hline
1024  &  32  ,  32  ,  32  &  0.925 \\[0.5ex]
\hline
1024  &  64  ,  64  ,  64  &  0.931 \\[0.5ex]
\hline
1024  &  128  ,  128  ,  128  &  0.920 \\[0.5ex]
\hline
1024  &  256  ,  256  ,  256  &  0.917 \\[0.5ex]
\hline
1024  &  512  ,  512  ,  512  &  0.899 \\[0.5ex]
\hline
1024  &  1024  ,  1024  ,  1024  &  0.858 \\[0.5ex]
\hline
1024  &  2048  ,  2048  ,  2048  &  0.776 \\[0.5ex]
\hline
2048  &  32  ,  32  ,  32  &  0.933 \\[0.5ex]
\hline
2048  &  64  ,  64  ,  64  &  0.934 \\[0.5ex]
\hline
2048  &  128  ,  128  ,  128  &  0.925 \\[0.5ex]
\hline
2048  &  256  ,  256  ,  256  &  0.928 \\[0.5ex]
\hline
2048  &  512  ,  512  ,  512  &  0.907 \\[0.5ex]
\hline
2048  &  1024  ,  1024  ,  1024  &  0.878 \\[0.5ex]
\hline
2048  &  2048  ,  2048  ,  2048  &  0.798 \\[0.5ex]
 \hline
 \hline
\end{tabular}
\end{minipage}
\caption{filter window size}
\label{tab:config_filternum}
\end{table}


\end{document}

What I have so far

EDIT: I followed the second solution from here, and it somehow didn't work. I am not sure why.

croppedImage

Best Answer

I think the problem is that the way you have defined your two tabulars, the width is forced to be larger than the available page width. Also, the tabular does not agree on the boundaries set by the minipage.

I would recommend using the tabularx package and the booktabs package.

In the answer below, you can and should of course work a bit on the column widths. I recommend using the booktabs package as it helps in producing clear tables ready for publication. They recommend not to use any vertical lines, so I have omitted these in my answer. I have put a \scriptsize to help fit the data. The \noindent is because otherwise the minipages might not align next to each other.

I would recommend to discard data from the 2nd columns, as it is only repetitive data which does not help in readability of the table.

enter image description here

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\begin{document}
\begin{table}[htbp]
\noindent\scriptsize
\begin{minipage}[t]{0.5\textwidth}
\begin{tabularx}{\textwidth}[t]{X X X}
\toprule
number of entity filter (size 1) & number of context filters (size 2, size 3, size 4) & Accuracy\\ \midrule
32  &  32, 32, 32  &  0.835 \\ \midrule
32  &  64, 64, 64  &  0.821 \\ \midrule
32  &  128, 128, 128  &  0.819 \\ \midrule
32  &  256, 256, 256  &  0.749 \\ \midrule
32  &  512, 512, 512  &  0.683 \\ \midrule
32  &  1024, 1024, 1024  &  0.528 \\ \midrule
32  &  2048, 2048, 2048  &  0.235 \\ \midrule
64  &  32, 32, 32  &  0.850 \\ \midrule
64  &  64, 64, 64  &  0.816 \\ \midrule
64  &  128, 128, 128  &  0.786 \\ \midrule
64  &  256, 256, 256  &  0.795 \\ \midrule
64  &  512, 512, 512  &  0.765 \\ \midrule
64  &  1024, 1024, 1024  &  0.669 \\ \midrule
64  &  2048, 2048, 2048  &  0.331 \\ \midrule
128  &  32, 32, 32  &  0.920 \\ \midrule
128  &  64, 64, 64  &  0.890 \\ \midrule
128  &  128, 128, 128  &  0.886 \\ \midrule
128  &  256, 256, 256  &  0.846 \\ \midrule
128  &  512, 512, 512  &  0.789 \\ \midrule
128  &  1024, 1024, 1024  &  0.755 \\ \midrule
128  &  2048, 2048, 2048  &  0.488 \\ \midrule
256  &  32, 32, 32  &  0.920 \\ \midrule
256  &  64, 64, 64  &  0.922 \\ \midrule
256  &  128, 128, 128  &  0.912 \\ \midrule
256  &  256, 256, 256  &  0.877 \\ \midrule
256  &  512, 512, 512  &  0.872 \\ \midrule
256  &  1024, 1024, 1024  &  0.771 \\ \midrule
256  &  2048, 2048, 2048  &  0.683 \\ \midrule
\end{tabularx}
\end{minipage}%
\begin{minipage}[t]{0.5\textwidth}
\begin{tabularx}{\textwidth}[t]{XXX}
\toprule
number of entity filter (size 1) & number of context filters (size 2, size 3, size4) & Accuracy\\ \midrule
512  &  32, 32, 32  &  0.910 \\ \midrule
512  &  64, 64, 64  &  0.922 \\ \midrule
512  &  128, 128, 128  &  0.909 \\ \midrule
512  &  256, 256, 256  &  0.910 \\ \midrule
512  &  512, 512, 512  &  0.883 \\ \midrule
512  &  1024, 1024, 1024  &  0.730 \\ \midrule
512  &  2048, 2048, 2048  &  0.682 \\ \midrule
1024  &  32, 32, 32  &  0.925 \\ \midrule
1024  &  64, 64, 64  &  0.931 \\ \midrule
1024  &  128, 128, 128  &  0.920 \\ \midrule
1024  &  256, 256, 256  &  0.917 \\ \midrule
1024  &  512, 512, 512  &  0.899 \\ \midrule
1024  &  1024, 1024, 1024  &  0.858 \\ \midrule
1024  &  2048, 2048, 2048  &  0.776 \\ \midrule
2048  &  32, 32, 32  &  0.933 \\ \midrule
2048  &  64, 64, 64  &  0.934 \\ \midrule
2048  &  128, 128, 128  &  0.925 \\ \midrule
2048  &  256, 256, 256  &  0.928 \\ \midrule
2048  &  512, 512, 512  &  0.907 \\ \midrule
2048  &  1024, 1024, 1024  &  0.878 \\ \midrule
2048  &  2048, 2048, 2048  &  0.798 \\ \bottomrule
\end{tabularx}
\end{minipage}
\caption{filter window size}
\label{tab:config_filternum}
\end{table}
\end{document}