1

Im trying to make 2 tables side by side, however each table consist of 2 tabular. I have tried using minipage in order to put them side by side, but they keep overlapping

\begin{minipage}{.4\linewidth}
\begin{table}[H]
    \caption{Global caption}
      \caption{}
      \centering
        \begin{tabular}{rrrrrrr}
  \hline
 & 0,5\_sec & 1\_sec & 1,5\_sec & 2\_sec & 2,5\_sec & 3\_sec \\ 
  \hline
Conc a & 0.98 & 0.80 & 0.41 & 0.31 & 0.12 & 0.04 \\ 
  Conc b & 0.24 & 0.12 & 0.10 & 0.09 & 0.39 & 0.68 \\ 
  Conc c & 0.20 & 0.05 & 0.02 & 0.00 & 0.00 & 0.00 \\ 
  Conc d & 0.34 & 0.46 & 0.43 & 0.47 & 0.64 & 0.82 \\ 
  Conc e & 0.34 & 0.45 & 0.50 & 0.33 & 0.23 & 0.09 \\ 
  Conc x & 0.01 & 0.00 & 0.00 & 0.02 & 0.02 & 0.04 \\ 
  Conc y & 0.45 & 0.87 & 0.48 & 0.49 & 0.60 & 0.86 \\ 
   \hline
\end{tabular}%
    \hspace{1.5cm}%
  \hspace{5.5cm}
  \subfloat[Male]{%
    \hspace{.5cm}%
\begin{tabular}{rrrrrrr}
  \hline
 & 0,5\_sec & 1\_sec & 1,5\_sec & 2\_sec & 2,5\_sec & 3\_sec \\ 
  \hline
Conc a & 0.07 & 0.15 & 0.17 & 0.09 & 0.04 & 0.04 \\ 
  Conc b & 0.54 & 0.72 & 0.75 & 0.86 & 0.74 & 0.75 \\ 
  Conc c & 0.29 & 0.53 & 0.54 & 0.54 & 0.67 & 0.81 \\ 
  Conc d & 0.01 & 0.00 & 0.00 & 0.00 & 0.01 & 0.03 \\ 
  Conc e & 0.47 & 0.78 & 0.90 & 0.80 & 0.82 & 1.00 \\ 
  Conc x & 0.06 & 0.05 & 0.11 & 0.26 & 0.43 & 0.56 \\ 
  Conc y & 0.05 & 0.03 & 0.03 & 0.12 & 0.14 & 0.12 \\ 
   \hline
\end{tabular}}%
\end{table}
    \end{minipage}%
    \begin{minipage}{.4\linewidth}
    \begin{table}[H]
      \centering
        \caption{}
       \begin{tabular}{rrrrrrr}
  \hline
 & 0,5\_sec & 1\_sec & 1,5\_sec & 2\_sec & 2,5\_sec & 3\_sec \\ 
  \hline
Conc a & 0.98 & 0.75 & 0.36 & 0.25 & 0.14 & 0.07 \\ 
  Conc b & 0.40 & 0.25 & 0.24 & 0.22 & 0.56 & 0.76 \\ 
  Conc c & 0.23 & 0.06 & 0.03 & 0.00 & 0.00 & 0.00 \\ 
  Conc d & 0.37 & 0.46 & 0.42 & 0.46 & 0.62 & 0.81 \\ 
  Conc e & 0.24 & 0.30 & 0.34 & 0.13 & 0.04 & 0.00 \\ 
  Conc x & 0.09 & 0.05 & 0.03 & 0.10 & 0.10 & 0.14 \\ 
  Conc y & 0.48 & 0.89 & 0.58 & 0.57 & 0.66 & 0.86 \\ 
   \hline
\end{tabular}%
    \hspace{1.5cm}%
  \hspace{5.5cm}
  \subfloat[Male]{%
    \hspace{.5cm}%
\begin{tabular}{rrrrrrr}
  \hline
 & 0,5\_sec & 1\_sec & 1,5\_sec & 2\_sec & 2,5\_sec & 3\_sec \\ 
  \hline
Conc a & 0.07 & 0.16 & 0.16 & 0.09 & 0.05 & 0.07 \\ 
  Conc b & 0.60 & 0.78 & 0.81 & 0.89 & 0.81 & 0.82 \\ 
  Conc c & 0.31 & 0.36 & 0.36 & 0.40 & 0.67 & 0.80 \\ 
  Conc d & 0.00 & 0.00 & 0.00 & 0.00 & 0.01 & 0.02 \\ 
  Conc e & 0.52 & 0.81 & 0.91 & 0.80 & 0.82 & 1.00 \\ 
  Conc x & 0.11 & 0.11 & 0.21 & 0.39 & 0.52 & 0.59 \\ 
  Conc y & 0.02 & 0.01 & 0.01 & 0.04 & 0.06 & 0.06 \\ 
   \hline
\end{tabular}}%
\end{table}
    \end{minipage} 

I would like to have the two tables with concentrations a,b,c... in one minipage and the tables with concentrations 1,2,3... on a minipage right next to it. If there is another possible solution that doesn't use minipage im up for that as well

EDIT: Fixed one problem, but got another, now i get the tables but they overlap. How do i avoid that?

migrated from stackoverflow.com Apr 26 '16 at 5:53

This question came from our site for professional and enthusiast programmers.

  • I got it to work with 2 minipages and moving minipage up, but they are still overlapping... Any suggestions? – Mikkel Astrup Apr 12 '16 at 15:07
  • Your tables are huge, that's the reason for problems -- larger than the environments they go in. There are tricks to play, using boxes but I couldn't get it to look OK. Will post when I do. – zdim Apr 13 '16 at 9:40
  • Welcome to SE! Newer put floats inside minipages! – Zarko Apr 26 '16 at 5:57
  • How wide is your document's text block? – Mico Apr 26 '16 at 6:21
1

This is more comment than answer. In your MWE you have several problems:

  • float inside minipages: this should cause errors
  • table are too wide to fit in text width in the portrait page orientation (Even if you rotate column heads for 90 and reduce font size to tiny one table pair is still wider than half of text width. Consequently tabulars will overlap)

For the second problem you can (i) squeeze to unreadable small tables, (ii) put table one over other or (iii) use landscape orientation. For second case you can obtain:

enter image description here

The MWE for above image of tables is:

\documentclass{article}
\usepackage[margin=25mm,showframe]{geometry}    

\usepackage{subfig}

    \begin{document}
\begin{table}[htb]
    \setlength{\tabcolsep}{3pt}
    \centering
\caption{Global caption}
\subfloat[sub table 1]{
       \begin{tabular}{*{7}{r}}
  \hline
 & 0,5\_sec & 1\_sec & 1,5\_sec & 2\_sec & 2,5\_sec & 3\_sec \\
  \hline
Conc a & 0.98 & 0.75 & 0.36 & 0.25 & 0.14 & 0.07 \\
  Conc b & 0.40 & 0.25 & 0.24 & 0.22 & 0.56 & 0.76 \\
  Conc c & 0.23 & 0.06 & 0.03 & 0.00 & 0.00 & 0.00 \\
  Conc d & 0.37 & 0.46 & 0.42 & 0.46 & 0.62 & 0.81 \\
  Conc e & 0.24 & 0.30 & 0.34 & 0.13 & 0.04 & 0.00 \\
  Conc x & 0.09 & 0.05 & 0.03 & 0.10 & 0.10 & 0.14 \\
  Conc y & 0.48 & 0.89 & 0.58 & 0.57 & 0.66 & 0.86 \\
   \hline
\end{tabular}%
\qquad
\begin{tabular}{*{7}{r}}
  \hline
 & 0,5\_sec & 1\_sec & 1,5\_sec & 2\_sec & 2,5\_sec & 3\_sec \\
  \hline
Conc a & 0.07 & 0.16 & 0.16 & 0.09 & 0.05 & 0.07 \\
  Conc b & 0.60 & 0.78 & 0.81 & 0.89 & 0.81 & 0.82 \\
  Conc c & 0.31 & 0.36 & 0.36 & 0.40 & 0.67 & 0.80 \\
  Conc d & 0.00 & 0.00 & 0.00 & 0.00 & 0.01 & 0.02 \\
  Conc e & 0.52 & 0.81 & 0.91 & 0.80 & 0.82 & 1.00 \\
  Conc x & 0.11 & 0.11 & 0.21 & 0.39 & 0.52 & 0.59 \\
  Conc y & 0.02 & 0.01 & 0.01 & 0.04 & 0.06 & 0.06 \\
   \hline
\end{tabular}%
            }

    \subfloat[sub table 2]{
        \begin{tabular}{*{7}{r}}
  \hline
 & 0,5\_sec & 1\_sec & 1,5\_sec & 2\_sec & 2,5\_sec & 3\_sec \\
  \hline
Conc a & 0.98 & 0.80 & 0.41 & 0.31 & 0.12 & 0.04 \\
  Conc b & 0.24 & 0.12 & 0.10 & 0.09 & 0.39 & 0.68 \\
  Conc c & 0.20 & 0.05 & 0.02 & 0.00 & 0.00 & 0.00 \\
  Conc d & 0.34 & 0.46 & 0.43 & 0.47 & 0.64 & 0.82 \\
  Conc e & 0.34 & 0.45 & 0.50 & 0.33 & 0.23 & 0.09 \\
  Conc x & 0.01 & 0.00 & 0.00 & 0.02 & 0.02 & 0.04 \\
  Conc y & 0.45 & 0.87 & 0.48 & 0.49 & 0.60 & 0.86 \\
   \hline
\end{tabular}%
\qquad
\begin{tabular}{*{7}{r}}
  \hline
 & 0,5\_sec & 1\_sec & 1,5\_sec & 2\_sec & 2,5\_sec & 3\_sec \\
  \hline
Conc a & 0.07 & 0.15 & 0.17 & 0.09 & 0.04 & 0.04 \\
  Conc b & 0.54 & 0.72 & 0.75 & 0.86 & 0.74 & 0.75 \\
  Conc c & 0.29 & 0.53 & 0.54 & 0.54 & 0.67 & 0.81 \\
  Conc d & 0.01 & 0.00 & 0.00 & 0.00 & 0.01 & 0.03 \\
  Conc e & 0.47 & 0.78 & 0.90 & 0.80 & 0.82 & 1.00 \\
  Conc x & 0.06 & 0.05 & 0.11 & 0.26 & 0.43 & 0.56 \\
  Conc y & 0.05 & 0.03 & 0.03 & 0.12 & 0.14 & 0.12 \\
   \hline
\end{tabular}%
    }% 
\end{table}
    \end{document}

If you use \tiny font size and rotate column heads, you obtain

enter image description here

Based on both options you can decide what to do.

Your Answer

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