2

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

1

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}
  • 1
    can you elaborate more on what you mean by 'forced larger than available page width'? I've set minipage width to be 0.2 of textwidth. Isn't that enough to guarantee my minipage is fractional to the page width? – Daniel Aug 1 '16 at 6:59
  • Sorry @Daniel, I should have included fixed source code instead of an abstract description, which is indeed no answer conform the standards. I meant that the colums in total where to wide to fit altogether, as Johannes_B refers to as an elephant in a suitcase ;) – Lucademicus Aug 2 '16 at 7:48
  • @Daniel I have included a complete answer – Lucademicus Aug 2 '16 at 9:18
2

You cannot fit an elephant in a suitcase. Here is an alternative: Make the font a bit smaller and extend the printable area just for the table. The black rule shows how wide the typearea currently is.

danielTabular

\documentclass{article}
\usepackage{array}
\usepackage{showframe}
\usepackage{booktabs}
\usepackage{scrextend}
\usepackage{ragged2e}
\begin{document}
\begin{table}%[htbp]%JB Never use that right from the start. This is for polishing at the end
    \begin{addmargin*}[0pt]{-10em}
        \rule{\linewidth}{2ex}
    \small
    \begin{tabular}[t]{ >{\RaggedRight}m{.12\linewidth}  >{\RaggedRight}m{.2\linewidth}  c } 
            \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 \\
            32                               & 64  ,  64  ,  64                                   & 0.821 \\
            32                               & 128  ,  128  ,  128                                & 0.819 \\
            32                               & 256  ,  256  ,  256                                & 0.749 \\
            32                               & 512  ,  512  ,  512                                & 0.683 \\
            32                               & 1024  ,  1024  ,  1024                             & 0.528 \\
            32                               & 2048  ,  2048  ,  2048                             & 0.235 \\
            64                               & 32  ,  32  ,  32                                   & 0.850 \\
            64                               & 64  ,  64  ,  64                                   & 0.816 \\
            64                               & 128  ,  128  ,  128                                & 0.786 \\
            64                               & 256  ,  256  ,  256                                & 0.795 \\
            64                               & 512  ,  512  ,  512                                & 0.765 \\
            64                               & 1024  ,  1024  ,  1024                             & 0.669 \\
            64                               & 2048  ,  2048  ,  2048                             & 0.331 \\
            128                              & 32  ,  32  ,  32                                   & 0.920 \\
            128                              & 64  ,  64  ,  64                                   & 0.890 \\
            128                              & 128  ,  128  ,  128                                & 0.886 \\
            128                              & 256  ,  256  ,  256                                & 0.846 \\
            128                              & 512  ,  512  ,  512                                & 0.789 \\
            128                              & 1024  ,  1024  ,  1024                             & 0.755 \\
            128                              & 2048  ,  2048  ,  2048                             & 0.488 \\
            256                              & 32  ,  32  ,  32                                   & 0.920 \\
            256                              & 64  ,  64  ,  64                                   & 0.922 \\
            256                              & 128  ,  128  ,  128                                & 0.912 \\
            256                              & 256  ,  256  ,  256                                & 0.877 \\
            256                              & 512  ,  512  ,  512                                & 0.872 \\
            256                              & 1024  ,  1024  ,  1024                             & 0.771 \\
            256                              & 2048  ,  2048  ,  2048                             & 0.683 \\
            \bottomrule
        \end{tabular}\hfill%
        \begin{tabular}[t]{ >{\RaggedRight}m{.12\linewidth}  >{\RaggedRight}m{.2\linewidth}  c } 
            \toprule
            number of entity filter (size 1) & number of context filters (size 2, size 3, size 4) & Accuracy\\
            \midrule
            512                              & 32  ,  32  ,  32                                  & 0.910 \\
            512                              & 64  ,  64  ,  64                                  & 0.922 \\
            512                              & 128  ,  128  ,  128                               & 0.909 \\
            512                              & 256  ,  256  ,  256                               & 0.910 \\
            512                              & 512  ,  512  ,  512                               & 0.883 \\
            512                              & 1024  ,  1024  ,  1024                            & 0.730 \\
            512                              & 2048  ,  2048  ,  2048                            & 0.682 \\
            1024                             & 32  ,  32  ,  32                                  & 0.925 \\
            1024                             & 64  ,  64  ,  64                                  & 0.931 \\
            1024                             & 128  ,  128  ,  128                               & 0.920 \\
            1024                             & 256  ,  256  ,  256                               & 0.917 \\
            1024                             & 512  ,  512  ,  512                               & 0.899 \\
            1024                             & 1024  ,  1024  ,  1024                            & 0.858 \\
            1024                             & 2048  ,  2048  ,  2048                            & 0.776 \\
            2048                             & 32  ,  32  ,  32                                  & 0.933 \\
            2048                             & 64  ,  64  ,  64                                  & 0.934 \\
            2048                             & 128  ,  128  ,  128                               & 0.925 \\
            2048                             & 256  ,  256  ,  256                               & 0.928 \\
            2048                             & 512  ,  512  ,  512                               & 0.907 \\
            2048                             & 1024  ,  1024  ,  1024                            & 0.878 \\
            2048                             & 2048  ,  2048  ,  2048                            & 0.798 \\
            \bottomrule
        \end{tabular}
    \caption{filter window size}
    \label{tab:config_filternum}
\end{addmargin*}
\end{table}
\end{document}
2

In my test your original code protrude right margin and are overlapped (as expected). Better approach is declare minipage width so, that both are fit in text width and than make columns in table narrowed (as stated Lucademicus in hos answer). For example:

\documentclass{article}
\usepackage{array,tabularx}
\newcolumntype{M}[1]{>{\raggedright\arraybackslash}m{#1}}

\renewcommand\tabularxcolumn[1]{b{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

\usepackage[showframe]{geometry}

\begin{document}
\begin{table}[htbp]
    \centering
\renewcommand\arraystretch{1.3}
\begin{minipage}[t]{.48\textwidth}
    \begin{tabular}[t]{| M{1.5cm} | M{3cm} | c |}
    \hline
 number of entity filter (size 1) & number of context filters (size 2, size 3,
 size 4) & Accuracy\\ 
 \hline
32  &  32  ,  32  ,  32  &  0.835 \\    \hline
32  &  64  ,  64  ,  64  &  0.821 \\    \hline
32  &  128  ,  128  ,  128  &  0.819 \\ \hline
32  &  256  ,  256  ,  256  &  0.749 \\ \hline
32  &  512  ,  512  ,  512  &  0.683 \\ \hline
32  &  1024  ,  1024  ,  1024  &  0.528 \\  \hline
32  &  2048  ,  2048  ,  2048  &  0.235 \\  \hline
64  &  32  ,  32  ,  32  &  0.850 \\    \hline
64  &  64  ,  64  ,  64  &  0.816 \\    \hline
64  &  128  ,  128  ,  128  &  0.786 \\ \hline
 \end{tabular}
\end{minipage}%
\hfill
\begin{minipage}[t]{.48\textwidth}
    \begin{tabular}[t]{| M{1.5cm} | M{3cm} | c |}
 \hline
 number of entity filter (size 1) & number of context filters (size 2, size 3,
 size4) & Accuracy\\                \hline
512  &  32  ,  32  ,  32  &  0.910 \\   \hline
512  &  64  ,  64  ,  64  &  0.922 \\   \hline
512  &  128  ,  128  ,  128  &  0.909 \\    \hline
512  &  256  ,  256  ,  256  &  0.910 \\    \hline
512  &  512  ,  512  ,  512  &  0.883 \\    \hline
512  &  1024  ,  1024  ,  1024  &  0.730 \\ \hline
512  &  2048  ,  2048  ,  2048  &  0.682 \\ \hline
1024  &  32  ,  32  ,  32  &  0.925 \\  \hline
1024  &  64  ,  64  ,  64  &  0.931 \\  \hline
1024  &  128  ,  128  ,  128  &  0.920 \\
 \hline
 \hline
\end{tabular}
\end{minipage}
\caption{filter window size}
\label{tab:config_filternum}
\end{table}

\begin{table}[htbp]
    \centering
\renewcommand\arraystretch{1.3}
    \begin{tabularx}{0.48\textwidth}{|>{\setlength\hsize{0.25\hsize}}L
                                        |>{\setlength\hsize{0.5\hsize}}L
                                        |>{\setlength\hsize{0.25\hsize}}C|}
    \hline
 number of entity filter (size 1) & number of context filters (size 2, size 3,
 size 4) & Accuracy\\
 \hline
32  &  32   ,  32   ,  32   &  0.835 \\     \hline
32  &  64   ,  64   ,  64   &  0.821 \\     \hline
32  &  128  ,  128  ,  128  &  0.819 \\     \hline
32  &  256  ,  256  ,  256  &  0.749 \\     \hline
32  &  512  ,  512  ,  512  &  0.683 \\     \hline
32  &  1024 ,  1024 ,  1024 &  0.528 \\     \hline
32  &  2048 ,  2048 ,  2048 &  0.235 \\     \hline
64  &  32   ,  32   ,  32   &  0.850 \\      \hline
64  &  64   ,  64   ,  64   &  0.816 \\    \hline
64  &  128  ,  128  ,  128  &  0.786 \\     \hline
 \end{tabularx}\hfill
    \begin{tabularx}{0.48\textwidth}{|>{\setlength\hsize{0.25\hsize}}L
                                        |>{\setlength\hsize{0.5\hsize}}L
                                        |>{\setlength\hsize{0.25\hsize}}C|}
 \hline
 number of entity filter (size 1) & number of context filters (size 2, size 3,
 size4) & Accuracy\\                \hline
512   &  32   ,  32   ,  32     &  0.910 \\     \hline
512   &  64   ,  64   ,  64     &  0.922 \\     \hline
512   &  128  ,  128  ,  128    &  0.909 \\     \hline
512   &  256  ,  256  ,  256    &  0.910 \\     \hline
512   &  512  ,  512  ,  512    &  0.883 \\     \hline
512   &  1024 ,  1024 ,  1024   &  0.730 \\     \hline
512   &  2048 ,  2048 ,  2048   &  0.682 \\     \hline
1024  &  32   ,  32   ,  32     &  0.925 \\     \hline
1024  &  64   ,  64   ,  64     &  0.931 \\     \hline
1024  &  128  ,  128  ,  128    &  0.920 \\
    \hline
    \hline
\end{tabularx}

\caption{filter window size}
\label{tab:config_filternum}
\end{table}
\end{document}

first table gives:

enter image description here

however, the second part of above MWE is suggest to use tabularx without minipages which gives:

enter image description here

I use anly few rows of both table. In this I also remove all [0.5ex] and increase \arraystretch to 1.3.

Use of tabularx has befits, that you can define width of table and relative to this width are defined widths of columns. With this you are on safe side to place both table in parallel.

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.