1

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}
  • 1
    Welcome! Please provide a minimal working example that starts with \documentclass and ends with \end{document}. – marmot Dec 11 '17 at 18:15
1

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

  • Thank you. I do not want lines to break. The solution for table 2 worked best, I now how a readable table, but I will spend some time trying to understand what is going on in your two suggestions. – AnneDoe Dec 12 '17 at 11:06
0

for two parallel tables in float you not need minipages. for nicer text filing in cells i suggest to use RaggedRight command from ragged2e packages. also smaller font (but not smaller than \footnotesize) and tabcolsep will be of help:

\documentclass[11pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[skip=1ex]{caption}
\usepackage{ragged2e}
\usepackage{array}
\newcolumntype{R}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}

\begin{document}
    \begin{table}[ht]
\caption{blablabla}
\centering
\renewcommand\arraystretch{1.2}
\setlength\tabcolsep{3pt}
\small
%
\begin{tabular}[t]{R{2.5cm}c|R{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}\hfill
\begin{tabular}[t]{R{2.5cm}c|R{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{table}
\end{document}

enter image description here

edit:

if you like to stick both table together, than in above mwe replace lines

\end{tabular}\hfill
\begin{tabular}[t]{R{2.5cm}c|R{2.5cm}c}

with:

\end{tabular}%
\begin{tabular}[t]{R{2.5cm}c|R{2.5cm}c}

and with use of \footnotesize for font size you will obtain:

enter image description here

however, i wonder, why you not set this tables as one in the first place?

  • Thank you. I honestly don't quite understand the usage of minipage, I just googled how to make to tables side-by-side, and most of the suggestions contained minipage. I will spend some more time trying to perfectionize my tables later, and study your suggestion. What if I don't want lines to break? – AnneDoe Dec 12 '17 at 11:09
  • then replace \hfill after end{tabular} with sign % – Zarko Dec 12 '17 at 13:30
  • @AnneDoe, see edit of my answer – Zarko Dec 12 '17 at 17:14
  • Thank you, again. Does the % itself have any function? I thought it was just for commenting. And you've got a very good point. I started off with two separate tables on two separate pages, and later figured out I wanted them side by side. Making one table would probably be much wiser now that I know I want them on one page. – AnneDoe Dec 19 '17 at 11:45
  • @AnneDoe, with% is deleted any space after it, i.e. if it follow immediately after the first table (as is in my code above), the second table is tied to the first. – Zarko Dec 19 '17 at 13:18

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.