1

I am trying to align tables side by side in latex but i was unable to do using minipage. I have mentioned the latex code below to make the table side by side

\begin{minipage}[t]{0.4\textwidth}

\begin{tabular}{l*{6}{c}r}

I32             & optimizer & Loss & PSNR  \\
\hline
      & Adam     & Mean Square Error   & 0    \\
     & Adam     & DSSIM               & 0    \\
     & Adam     & PSNR loss           & 1    \\
     & Adam     & Mean Absolute Error & 1    \\
     & Ranger   & Mean Absolute Error + Mean Gradient Error & \\
     & Ranger   & Mean Absolute Error + Mean Gradient Error + KL Loss &\\
     & Ranger   & Mean Absolute Error + KL Loss & \\
     & Ranger   & Mean Absolute Error + KL Loss + Mean Gradient Error &\\
     & Ranger21 & Mean Absolute Error & \\
     & Ranger21 & Mean Absolute Error + KL Loss & \\
     & Ranger21 & Mean Absolute Error + 0.75 KL Loss & \\
     & Ranger21 & Mean Absolute Error + 0.5 KL Loss & \\
\hline
\end{tabular}

\end{minipage}

\begin{minipage}[t]{0.4\textwidth}
\begin{tabular}{l*{6}{c}r}
I43 & optimizer & Loss & PSNR  \\
\hline
    & Adam     & Mean Square Error   & 0    \\
     & Adam     & DSSIM               & 0    \\
     & Adam     & PSNR loss           & 1    \\
     & Adam     & Mean Absolute Error & 1    \\
     & Ranger   & Mean Absolute Error + Mean Gradient Error & \\
     & Ranger   & Mean Absolute Error + Mean Gradient Error + KL Loss &\\
     & Ranger   & Mean Absolute Error + KL Loss & \\
     & Ranger   & Mean Absolute Error + KL Loss + Mean Gradient Error &\\
     & Ranger21 & Mean Absolute Error & \\
     & Ranger21 & Mean Absolute Error + KL Loss & \\
     & Ranger21 & Mean Absolute Error + 0.75 KL Loss & \\
     & Ranger21 & Mean Absolute Error + 0.5 KL Loss & \\
\hline
\end{tabular}

\end{minipage}

enter image description here

10
  • Welcome to TeX.SX! To get two minipages sidy by side on a page, remove the empty line between the them. Apart from that, your tables look quite wide and I would guess, thex don't fit side by side onto a portrait page. Do you get any overfull \box warnings if you compile your code?
    – leandriis
    Jul 23 at 6:45
  • 1
    Since both tables are quite wide and unlikely to fit side by side and on top of that share a lot of the same information, would you mind combining them into a single table? Also, what exactly is the difference between the two tables (apart from the number in the upper left cell)?
    – leandriis
    Jul 23 at 6:53
  • 1
    Wrapping a table in a \scalebox will result in inconsistenz font sizes throughout the document. You may want to avoid that.
    – leandriis
    Jul 23 at 6:56
  • 1
    Do all 16 tables share the same entries in the "optimizer" and "loss" columns and only differ in the numbers in the "PSNR" column? If so, there is not really a reason for repeating this information 16 times. A combined table could for example look like this:: i.stack.imgur.com/m7VTo.png
    – leandriis
    Jul 23 at 6:57
  • 1
    How wide and how tall is the text block? Alternatively, which page size do you employ and how wide are the margins?
    – Mico
    Jul 23 at 7:12
1

I suggest one of the following two alternative layouts, that use just 2 instead of 16 tables as well as abbreviations (similar to the ones used by Mico in their answer)

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{geometry}

\begin{document}

\begin{table}
\centering

\begin{tabular}{l*{8}{c}}
\toprule
               & \multicolumn{8}{c}{PSNR}\\
\cmidrule{2-9}
 Loss &  (I32) &  (I43) &  (I87) &  (I32) &  (I43) &  (I87) &  (I32) &  (I43)  \\
\midrule
\multicolumn{1}{@{}l}{Adam}\\
 MSE   & 0   & 0 & 0 \\
 DSSIM               & 0   & 0 & 0  \\
 PSNR loss           & 1   & 1 & 1 \\
 MAE & 1   & 1 & 1 \\
\addlinespace
\multicolumn{1}{@{}l}{Ranger}\\
 MAE + MGE           & \\
 MAE + MGE + KLL &\\
 MAE + KLL & \\
 MAE + KLL + MGE &\\
\addlinespace
\multicolumn{1}{@{}l}{Ranger21}\\
 MAE& \\
 MAE + KLL & \\
 MAE + 0.75 KLL & \\
 MAE + 0.5 KLL & \\
 \midrule
                & \multicolumn{8}{c}{PSNR}\\
\cmidrule{2-9}
 Loss &  (I32) &  (I43) &  (I87) &  (I32) &  (I43) &  (I87) &  (I32) &  (I43)  \\
\midrule
\multicolumn{1}{@{}l}{Adam}\\
 MSE   & 0   & 0 & 0 \\
 DSSIM               & 0   & 0 & 0  \\
 PSNR loss           & 1   & 1 & 1 \\
 MAE & 1   & 1 & 1 \\
\addlinespace
\multicolumn{1}{@{}l}{Ranger}\\
 MAE + MGE           & \\
 MAE + MGE + KL Loss &\\
 MAE + KL Loss & \\
 MAE + KL Loss + MGE &\\
\addlinespace
\multicolumn{1}{@{}l}{Ranger21}\\
 MAE& \\
 MAE + KLL & \\
 MAE + 0.75 KL Loss & \\
 MAE + 0.5 KL Loss & \\
\bottomrule
\end{tabular}
\smallskip

\footnotesize
MSE: Mean Square Error; MAE: Mean Absolute Error; MGE: Mean Gradient Error

\end{table}


\begin{table}
\centering
\begin{tabular}{ll*{8}{c}}
\toprule
               && \multicolumn{8}{c}{PSNR}\\
\cmidrule{3-10}
optimizer  & Loss &  (I32) &  (I43) &  (I87) &  (I32) &  (I43) &  (I87) &  (I32) &  (I43)  \\
\midrule
Adam & MSE       & 0   & 0 & 0 \\
     & DSSIM     & 0   & 0 & 0  \\
     & PSNR loss & 1   & 1 & 1 \\
     & MAE       & 1   & 1 & 1 \\
\addlinespace
Range &  MAE + MGE           & \\
      & MAE + MGE + KLL &\\
      & MAE + KLL & \\
      & MAE + KLL + MGE &\\
\addlinespace
Ranger21 & MAE& \\
         & MAE + KLL & \\
         & MAE + 0.75 KLL & \\
         & MAE + 0.5 KLL & \\
\midrule
               && \multicolumn{8}{c}{PSNR}\\
\cmidrule{3-10}
optimizer  & Loss &  (I32) &  (I43) &  (I87) &  (I32) &  (I43) &  (I87) &  (I32) &  (I43)  \\
\midrule
Adam & MSE       & 0   & 0 & 0 \\
     & DSSIM     & 0   & 0 & 0  \\
     & PSNR loss & 1   & 1 & 1 \\
     & MAE       & 1   & 1 & 1 \\
\addlinespace
Range &  MAE + MGE           & \\
      & MAE + MGE + KLL &\\
      & MAE + KLL & \\
      & MAE + KLL + MGE &\\
\addlinespace
Ranger21 & MAE& \\
         & MAE + KLL & \\
         & MAE + 0.75 KLL & \\
         & MAE + 0.5 KLL & \\
\bottomrule
\end{tabular}
\smallskip

\footnotesize
MSE: Mean Square Error; MAE: Mean Absolute Error; MGE: Mean Gradient Error

\end{table}

\end{document}
1

You need to drastically simplify and streamline the tables just to get two tables to fit side by side. The following code gives an example of how this may be done.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters suitably
\begin{document}

\noindent
\begin{tabular}[t]{ @{} llc @{} }
\multicolumn{3}{@{}l}{\textbf{I32}}\\
Optimizer & Loss & PSNR \\
\hline
Adam     & MSE        & 0   \\
Adam     & DSSIM      & 0   \\
Adam     & PSNR loss  & 1   \\
Adam     & MAE        & 1   \\
Ranger   & MAE + MGE  &     \\
Ranger   & MAE + MGE + KLL &\\
Ranger   & MAE + KLL  &     \\
Ranger   & MAE + KLL + MGE &\\
Ranger21 & MAE        &     \\
Ranger21 & MAE + KLL  &     \\
Ranger21 & MAE + 0.75 KLL & \\
Ranger21 & MAE + 0.5 KLL &  \\
\hline
\end{tabular}\hspace{\fill}
\begin{tabular}[t]{ @{} llc @{} }
\multicolumn{3}{@{}l}{\textbf{I43}}\\
Optimizer & Loss & PSNR \\
\hline
Adam     & MSE       & 0    \\
Adam     & DSSIM     & 0    \\
Adam     & PSNR loss & 1    \\
Adam     & MAE       & 1    \\
Ranger   & MAE + MGE &      \\
Ranger   & MAE + MGE + KLL &\\
Ranger   & MAE + KLL &      \\
Ranger   & MAE + KLL + MGE &\\
Ranger21 & MAE       &      \\
Ranger21 & MAE + KLL &      \\
Ranger21 & MAE + 0.75 KLL & \\
Ranger21 & MAE + 0.5 KLL &  \\
\hline
\end{tabular}

\bigskip
\noindent
\dots
\end{document}

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.