如何并排放置两个表格

如何并排放置两个表格

我有两个表,但我想在 latex 中将它们并排放置,需要帮助。我尝试过使用tabular,但出现错误,也许我做错了

\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 \\
 \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 \\
\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 \\

\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 \\

\end{tabular}
\smallskip

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

\end{table}

\end{document}

答案1

如果您想要并排查看两个表格,请以横向模式进行,每个表格都包含在一个 parbox 中。

我没有改变表格的任何内容。为了更好地匹配,它们的列数和行数不同,因此我在右侧表格的两个地方添加了换行符。

b

\documentclass[landscape]{article}
\usepackage{booktabs}
\usepackage[left=1.5cm,right=1cm]{geometry}% changed<<<<<<<<<<

\begin{document}
        
\noindent
\parbox[b]{0.45\textwidth}{%
            \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 \\
            \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 \\
            \bottomrule
        \end{tabular}
    \smallskip
    
\footnotesize
MSE: Mean Square Error; MAE: Mean Absolute Error; MGE: Mean Gradient Error}
\parbox[b]{0.5\textwidth}{%
            \begin{tabular}{ll*{8}{c}}
            \toprule
            && \multicolumn{8}{c}{PSNR}\\
            \cmidrule{3-10}
            optimizer  & Loss &  (I32) &  (I43) &  (I87) &  (I32) &  (I43) &  (I87) &  (I32) &  (I43)  \\
            \midrule \\ % changed <<<<
            Adam & MSE       & 0   & 0 & 0 \\
            & DSSIM     & 0   & 0 & 0  \\
            & PSNR loss & 1   & 1 & 1 \\
            & MAE       & 1   & 1 & 1 \\ 
            \midrule
            && \multicolumn{8}{c}{PSNR}\\
            \cmidrule{3-10}
            optimizer  & Loss &  (I32) &  (I43) &  (I87) &  (I32) &  (I43) &  (I87) &  (I32) &  (I43)  \\
            \midrule \\ % changed <<<<
            Adam & MSE       & 0   & 0 & 0 \\
            & DSSIM     & 0   & 0 & 0  \\
            & PSNR loss & 1   & 1 & 1 \\
            & MAE       & 1   & 1 & 1 \\
            \bottomrule     
        \end{tabular}
        \smallskip
        
        \footnotesize
        MSE: Mean Square Error; MAE: Mean Absolute Error; MGE: Mean Gradient Error}
        
\end{document}

相关内容