[Tex/LaTex] How prevent the side-by-side tables from overlapping

minipagesidebysidetables

I have two long tables, that I want side-by-side. When I use country codes they are OK, but as I want to use country names instead, they get too wide and overlap. As far as I can see, there is still plenty of space left on the page for the tables to be side by side without overlapping. I don't need to make the tables look very nice (yet), I just need them to be readable.

\documentclass[a4paper,12pt,times]{article}
\begin{document}    
\begin{table}
    \centering
    \caption{blablabla}
    \resizebox{0.6\textwidth}{!}{


     \begin{minipage}{.5\linewidth}
      \centering
    \begin{tabular}{lc|lc}
    \multicolumn{2}{l}{OLS} & \multicolumn{2}{r}{OLS}\tabularnewline
    \hline 
    \multicolumn{4}{c}{Negative}\tabularnewline
    \hline 
    A very very long country name & -0.00 & A very very long country name & -0.00\tabularnewline
    A very very long country name & -0.00 & A very very long country name & -0.00\tabularnewline

    \end{tabular}
    \end{minipage} 

    \hfill


    \begin{minipage}{.5\linewidth}
     \centering

    \begin{tabular}{lc|lc}
    \multicolumn{2}{l}{OLS} & \multicolumn{2}{r}{OLS}\tabularnewline
    \hline 
    \multicolumn{4}{c}{Negative}\tabularnewline
    \hline 
    A very very long country name & -1.00 & A very very long country name & -0.00\tabularnewline
    A very very long country name & -0.4 & A very very long country name & -0.01\tabularnewline

    \end{tabular}
    \end{minipage}} 
    \end{table}
\end{document}

Best Answer

The tables are overlapping because you squeeze them into minipages of fixed width. Maybe the following snippet helps you to find a better solution. Notice, however, that I had to guess a document class and a preamble.

\documentclass[11pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{graphicx}
\usepackage{array}
\begin{document}
Your original minipages were not wide enough to fit all the stuff you put there.
However, were also using a \texttt{tabular} environment, which prevented the
lines from breaking. Since you were using the \texttt{minipage} environment, I'm
wondering if you want the text to break. In that case consider
\begin{table}[h]
\centering
\caption{blablabla}
\begin{tabular}{cc}
 \begin{minipage}{.5\linewidth}
  \centering
\begin{tabular}{p{2.5cm}c|p{2.5cm}c}
\multicolumn{2}{l}{OLS} & \multicolumn{2}{r}{OLS}\tabularnewline
\hline 
\multicolumn{4}{c}{Negative}\tabularnewline
\hline 
A very very long country name & -0.00 & A very very long country name & -0.00\tabularnewline
A very very long country name & -0.00 & A very very long country name & -0.00\tabularnewline
\end{tabular}
\end{minipage} 
&
\begin{minipage}{.5\linewidth}
 \centering
\begin{tabular}{p{2.5cm}c|p{2.5cm}c}
\multicolumn{2}{l}{OLS} & \multicolumn{2}{r}{OLS}\tabularnewline
\hline 
\multicolumn{4}{c}{Negative}\tabularnewline
\hline 
A very very long country name & -1.00 & A very very long country name & -0.00\tabularnewline
A very very long country name & -0.4 & A very very long country name & -0.01\tabularnewline
\end{tabular}
\end{minipage}%} 
\end{tabular}
\end{table}

If you really want to use resizebox, recall first that
\verb|\resizebox{0.6\textwidth}{!}{stuff}| scales stuff to 0.6$\times$textwidth,
which is probably not what you wanted. I'm assuming you wanted to use
\verb|\scalebox| instead. A somewhat more appropriate usage of \verb|\resizebox|
yields
\begin{table}[h]
\centering
\caption{blablabla}
\resizebox{\textwidth}{!}{%
\begin{tabular}{m{16cm}m{16cm}}
 \begin{minipage}{.5\linewidth} 
  \centering
\begin{tabular}{p{6cm}c|p{6cm}c}
\multicolumn{2}{l}{OLS} & \multicolumn{2}{r}{OLS}\tabularnewline
\hline 
\multicolumn{4}{c}{Negative}\tabularnewline
\hline 
A very very long country name & -0.00 & A very very long country name & -0.00\tabularnewline
A very very long country name & -0.00 & A very very long country name & -0.00\tabularnewline
\end{tabular}
\end{minipage} 
& 
\begin{minipage}{.5\linewidth}
 \centering
\begin{tabular}{p{6cm}c|p{6cm}c}
\multicolumn{2}{l}{OLS} & \multicolumn{2}{r}{OLS}\tabularnewline
\hline 
\multicolumn{4}{c}{Negative}\tabularnewline
\hline 
A very very long country name & -1.00 & A very very long country name & -0.00\tabularnewline
A very very long country name & -0.4 & A very very long country name & -0.01\tabularnewline
\end{tabular}
\end{minipage}% 
\end{tabular}%
}
\end{table}

However, for the sake of readability I'd recommend not use this method. 

\end{document}

enter image description here

Related Question