我正在尝试在 latex 中并排对齐表格,但我无法使用minipage
。我在下面提到了使表格并排的 latex 代码
\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}
答案1
我建议使用以下两种替代布局之一,它们只使用 2 个而不是 16 个表格以及缩写(类似于 Mico 使用的在他们的回答中)
\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}
答案2
您需要大幅简化和精简表格,才能使两个表格并排显示。以下代码给出了如何完成此操作的示例。
\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}