Latex 表格边距

Latex 表格边距

我已调整了 latex 表格的大小,以便将其放入两列文档中,如下面的代码所示。之后,表格注释似乎被移到了左侧。我希望表格注释与表格的左侧和右侧对齐。

\documentclass[layout=twocolumn]{article}
\usepackage[version=3]{mhchem} 
\usepackage{threeparttable}  
\begin{document}  
\begin{table}[htb] 
   \caption{My data}{\label{T:Table1}}
   \begin{threeparttable}
   \footnotesize \resizebox{\columnwidth}{!}{%\centering
        \begin{tabular}{l l lll }
           \hline
            test1 &test2 &  test3 &test4& test5  \\
           \hline\hline
            AA &  1      & 2      & 3   & 4   \\
            \hline\hline
         \end{tabular}}
    \begin{tablenotes}[para]
         \footnotesize
         \item I want to set the right side margin to the end of the table. The item is flushedto left side of thetable
    \end{tablenotes}
    \end{threeparttable}
\end{table}
\end{document}

在此处输入图片描述

答案1

为什么不使用tabularx。要使用,resizebox您还需要包括threeparttable环境。见下文。

\documentclass[layout=twocolumn]{article}
\usepackage[version=3]{mhchem} 
\usepackage{threeparttable}
\usepackage{tabularx}
\begin{document}  
\begin{table}[htb] 
   \caption{My data}{\label{T:Table1}}
   \resizebox{\columnwidth}{!}{%
         \begin{threeparttable}
        \begin{tabular}{l l lll }
           \hline
            test1 &test2 &  test3 &test4& test5  \\
           \hline\hline
            AA &  1      & 2      & 3   & 4   \\
            \hline\hline
         \end{tabular}
        \begin{tablenotes}[para]
      \footnotesize
             \item I want to set the right side margin to the end of the table. The item is flushedto left side of thetable
         \end{tablenotes}
 \end{threeparttable}}
\end{table}
\begin{table}[htb] 
   \caption{My data}{\label{T:Table2}}
         \begin{threeparttable}
             \begin{tabularx}{\columnwidth}{X l lll }
           \hline
            test1 &test2 &  test3 &test4& test5  \\
           \hline\hline
            AA &  1      & 2      & 3   & 4   \\
            \hline\hline
         \end{tabularx}
        \begin{tablenotes}[para]
      \footnotesize
             \item I want to set the right side margin to the end of the table. The item is flushedto left side of thetable
         \end{tablenotes}
 \end{threeparttable}
\end{table}

\end{document}

相关内容