1

I have the following MWE:

[\documentclass{article}

\begin{document}

\renewcommand{\arraystretch}{0.65}% For making the table tighter in the row heights
\begin{table}\[h\]

\centering
\begin{tabular}{cccccc}
\hlineB{2.5}
\multicolumn{5}{c}{SemEval - English}                    \\ 
\hlineB{2.5}
Model & Precision & Recall & Accuracy & F1-Score  \\
SVM     & 0.70      & 0.71   & 0.71     & \textbf{0.70}      \\
MNB     & 0.70      & 0.70   & 0.70     & 0.68      \\
Log Reg & 0.69      & 0.67   & 0.67     & 0.68      \\
KNN     & 0.56      & 0.66   & 0.66     & 0.59      \\
\hlineB{2.5}
\end{tabular}
\caption{SemEval on English \[Unigram\]}
\label{SemEval_English_Unigram}
\end{table}

\begin{table}\[h\]
\centering
\begin{tabular}{cccccc}
\hlineB{2.5}
\multicolumn{5}{c}{SemEval - English translation}                    \\ 
\hlineB{2.5}
Model & Precision & Recall & Accuracy & F1-Score  \\
SVM     & 0.78      & 0.72   & 0.72     & \textbf{0.74}      \\
MNB     & 0.77      & 0.69   & 0.69     & 0.71     \\
Log Reg & 0.79      & 0.68   & 0.68     & 0.71      \\
KNN     & 0.64      & 0.72   & 0.72     & 0.68      \\
\hlineB{2.5}
\end{tabular}
\caption{SemEval on English translation of German \[Unigram\]}
\label{SemEval_English_translation_Unigram}
\end{table}
\end{document}][1]

It outputs the tabales in 1. However, I would like the tables to be side-by-side with their own specific captions. I have tried using minpage as indicated in this post, but it ended with both tables overlapping a bit and I can't seem to figure out how to go about this.

Edit: Seems there was an issue with formatting when I posted, I am providing the code again in a code block.

\begin{table}[h]
\begin{minipage}{.4\textwidth}
\begin{tabular}{cccccc}
\hlineB{2.5}
\multicolumn{5}{c}{DIA - German}                    \\ 
\hlineB{2.5}
Model & Precision & Recall & Accuracy & F1-Score  \\
SVM     & 0.71      & 0.77   & 0.77     & 0.69      \\
MNB     & 0.65      & 0.78   & 0.78     & 0.68      \\
Log Reg & 0.69      & 0.73   & 0.73     & \textbf{0.71}      \\
KNN     & 0.60      & 0.77   & 0.77     & 0.68      \\
\hlineB{2.5}
\end{tabular}
\caption{DIA on German [Unigram]}
\label{DIA_on_German_Unigram}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{tabular}{cccccc}
\hlineB{2.5}
\multicolumn{5}{c}{DIA - German translation}                    \\ 
\hlineB{2.5}
Model & Precision & Recall & Accuracy & F1-Score  \\
SVM     & 0.71      & 0.70   & 0.70     & 0.61      \\
MNB     & 0.62      & 0.70   & 0.70     & 0.58      \\
Log Reg & 0.62      & 0.67   & 0.67     & \textbf{0.63}      \\
KNN     & 0.61      & 0.69   & 0.69     & 0.58      \\
\hlineB{2.5}
\end{tabular}
\caption{DIA on German translation [Unigram]}
\label{DIA_on_German_translation_Unigram}
\end{minipage}
\end{table}
5
  • Please copy and paste your code again so it isn't inside an image alt text. This has added all these wrong \[...\] Commented Aug 20, 2022 at 16:16
  • You could try to place them into minipages, if they overlap, the width of the minipages might have been too small. Please show the code. Commented Aug 20, 2022 at 16:17
  • I have posted the code with minipages in an edit, the tables are still overlapping after playing around with the textwidth.
    – birmignhamstudent
    Commented Aug 20, 2022 at 16:35
  • How is \hlineB{2.5} defined? Commented Aug 20, 2022 at 16:36
  • I haven't defined it at all, it is just a normal command like \hline as far as I know
    – birmignhamstudent
    Commented Aug 20, 2022 at 17:10

1 Answer 1

1

Your tables are too big to fit besides each other. In the layout you are using, they each are about 70% of the text width wide. two of them obviously are wider than the available space.

You can see this by decreasing the margin. If you decrease them to 2.4cm and remove some padding around the tables, they fit besides each other:

\documentclass{article}

\usepackage[margin=2.4cm]{geometry}

\begin{document}

\begin{table}[h]
\begin{minipage}{.5\textwidth}
\begin{tabular}{@{}cccccc@{}}
\hline
\multicolumn{5}{c}{DIA - German}                    \\ 
\hline
Model & Precision & Recall & Accuracy & F1-Score  \\
SVM     & 0.71      & 0.77   & 0.77     & 0.69      \\
MNB     & 0.65      & 0.78   & 0.78     & 0.68      \\
Log Reg & 0.69      & 0.73   & 0.73     & \textbf{0.71}      \\
KNN     & 0.60      & 0.77   & 0.77     & 0.68      \\
\hline
\end{tabular}
\caption{DIA on German [Unigram]}
\label{DIA_on_German_Unigram}
\end{minipage}%
\hfill
\begin{minipage}{0.5\textwidth}
\begin{tabular}{@{}cccccc@{}}
\hline
\multicolumn{5}{c}{DIA - German translation}                    \\ 
\hline
Model & Precision & Recall & Accuracy & F1-Score  \\
SVM     & 0.71      & 0.70   & 0.70     & 0.61      \\
MNB     & 0.62      & 0.70   & 0.70     & 0.58      \\
Log Reg & 0.62      & 0.67   & 0.67     & \textbf{0.63}      \\
KNN     & 0.61      & 0.69   & 0.69     & 0.58      \\
\hline
\end{tabular}
\caption{DIA on German translation [Unigram]}
\label{DIA_on_German_translation_Unigram}
\end{minipage}%
\end{table}


\end{document}

enter image description here


To safe some space, I suggest to combine your tables into one:

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{table}[h]
\centering
\begin{tabular}{@{} lcccccccc @{}}
\toprule
& \multicolumn{4}{c}{DIA - German} & \multicolumn{4}{c}{DIA - German translation}                       \\ 
\cmidrule(r){2-5}\cmidrule(l){6-9}
Model & Prec. & Re. & Acc. & F1-Score & Prec. & Rec. & Acc. & F1-Score  \\
SVM     & 0.71      & 0.77   & 0.77     & 0.69  & 0.71      & 0.70   & 0.70     & 0.61     \\
MNB     & 0.65      & 0.78   & 0.78     & 0.68   & 0.62      & 0.70   & 0.70     & 0.58    \\
Log Reg & 0.69      & 0.73   & 0.73     & \textbf{0.71}    & 0.62      & 0.67   & 0.67     & \textbf{0.63}    \\
KNN     & 0.60      & 0.77   & 0.77     & 0.68    & 0.61      & 0.69   & 0.69     & 0.58    \\
\bottomrule
\end{tabular}
\caption{...}
\end{table}

\end{document}

enter image description here

3
  • Thank you. Is there no other way to automatically resize the tables to fit? Changing the margin of the document messes up with other aspects of my entire thesis.
    – birmignhamstudent
    Commented Aug 20, 2022 at 17:11
  • @birmignhamstudent You could place them one below the other. Or choose a tiny-tiny font size, but that will be pain for your readers. Or you could decrease the space between the columns and use abbreviations for the header row, e.g. Acc. instead of Accurancy. Commented Aug 20, 2022 at 17:19
  • 1
    ... or you could combine them in one table, then you'd safe a whole column Commented Aug 20, 2022 at 17:21

You must log in to answer this question.