乳胶表行间距

乳胶表行间距

这个表格的标题和第一个编号行之间有多余的空格,这让我很抓狂,我不知道是什么造成了这种情况。非常感谢任何帮助!

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{ulem}
\usepackage{makecell}
\usepackage{placeins}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{indentfirst}
\usepackage{cleveref}
\usepackage{threeparttable}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{booktabs}
\usepackage[title]{appendix}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{natbib}
\renewcommand{\baselinestretch}{2} %Set spacing

\title{ }
\author{}
\date{}

\begin{}

             \begin{table}[h]                \refstepcounter{table}             \label{table:educ_dind_alt}                        \centering            \textbf{Table \ref{table:educ_dind_alt}. the title} \\            \begin{tabular}{@{\extracolsep{4pt}}l*{5}{c}@{}}          \hline \hline & \multicolumn{5}{c}{} \\        
                    &         (1)   &         (2)   &         (3)   &         (4)   &         (5)   \\
\hline
Variable            &       -0.08***&       -0.03*  &       -0.07***&       -0.03*  &       -0.03   \\
                    &      (0.02)   &      (0.01)   &      (0.02)   &      (0.01)   &      (0.02)   \\
\hline Demograpic Controls&               &           X   &           X   &           X   &           X   \\
State Year Trends   &               &               &           X   &               &               \\
Education Year Trends&               &               &               &           X   &               \\
Alternative Weight  &               &               &               &               &           X   \\
\hline \(R^2\)      &        0.71   &        0.71   &        0.73   &        0.71   &        0.82   \\
N                   &    1.90e+09   &    1.90e+09   &    1.90e+09   &    1.90e+09   &    1.98e+07   \\
            \noalign{\smallskip} \hline \hline             \end{tabular}            \medskip            \begin{minipage}{0.8\textwidth}             Notes: \( * p<0.05, ** p<0.01, *** p<0.005 \).            Notes here         \end{minipage}                \end{table}  

\end{document}

答案1

这是表格的两个不同版本。我希望您会同意第二个版本更具视觉吸引力并且更易于阅读。

在此处输入图片描述

在此处输入图片描述

\documentclass{article}

\usepackage[english]{babel}
\usepackage{makecell}
\usepackage{caption}
\usepackage{booktabs}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\captionsetup{font=bf}


\usepackage{siunitx}
\sisetup{input-symbols=()}

\begin{document}

\begin{table}
  \caption{some caption text}        
  \label{table:educ_dind_alt}                        
  \centering
  \begin{tabular}{@{\extracolsep{4pt}}l*{5}{c}@{}}
    \hline \hline %& \multicolumn{5}{c}{} \\  <---- Commented out to remove unwanted space       
                          &         (1)   &         (2)   &         (3)   &         (4)   &         (5)   \\
    \hline
    Variable              &       -0.08***&       -0.03*  &       -0.07***&       -0.03*  &       -0.03   \\
                          &      (0.02)   &      (0.01)   &      (0.02)   &      (0.01)   &      (0.02)   \\
    \hline 
    Demograpic Controls   &               &           X   &           X   &           X   &           X   \\
    State Year Trends     &               &               &           X   &               &               \\
    Education Year Trends &               &               &               &           X   &               \\
    Alternative Weight    &               &               &               &               &           X   \\
    \midrule \(R^2\)      &        0.71   &        0.71   &        0.73   &        0.71   &        0.82   \\
    N                     &    1.90e+09   &    1.90e+09   &    1.90e+09   &    1.90e+09   &    1.98e+07   \\
    \hline \hline             
  \end{tabular}
  \medskip
  \begin{minipage}{0.8\textwidth}
    Notes: \( * p<0.05, ** p<0.01, *** p<0.005 \). Notes here         
  \end{minipage}
\end{table}

\begin{table}[h!]
\caption{some caption text}        
\label{table:educ_dind_alt2}
\sisetup{input-symbols=(),
         table-align-text-post=false,
         table-format=-1.2,
         tight-spacing}

\centering
  \begin{tabular}{@{} l 
      *{3}{S[table-space-text-post={***}]} 
      *{2}{S[table-space-text-post={)}]} 
           @{}}
    \toprule        
                          &       {(1)}   &       {(2)}   &       {(3)}   &       {(4)}   &       {(5)}   \\
    \midrule
    Variable              &       -0.08***&       -0.03*  &       -0.07***&       -0.03*  &       -0.03   \\
                          &      (0.02)   &      (0.01)   &      (0.02)   &      (0.01)   &      (0.02)   \\ 
    \addlinespace 
    Demograpic Controls   &               &         {X}   &         {X}   &         {X}   &         {X}   \\ 
    \addlinespace
    State Year Trends     &               &               &         {X}   &               &               \\ 
    \addlinespace
    Education Year Trends &               &               &               &         {X}   &               \\ 
    \addlinespace
    Alternative Weight    &               &               &               &               &         {X}   \\ 
    \midrule 
    \(R^2\)               &        0.71   &        0.71   &        0.73   &        0.71   &        0.82   \\
    \(N\)                 & \num{1.90e+09}& \num{1.90e+09}& \num{1.90e+09}& \num{1.90e+09}& \num{1.98e+07}\\
    \bottomrule
    \addlinespace
    \multicolumn{6}{@{}l}{Notes: \(^{*} p<0.05\), \(^{**} p<0.01\), \(^{***} p<0.005 \). Notes here}         
  \end{tabular}
\end{table}  

\end{document}

答案2

在您的表中,我将使用两个新包:siunitxthreeparttablex。第一个用于S表中的列(第一列除外),第二个用于带有和的threepartable表环境。相反,我宁愿使用来自的规则:tablenotestnote\hlinebooktabs

在此处输入图片描述

\documentclass{article}
\usepackage[a4paper, total={6in, 8in}]{geometry}

\usepackage{booktabs}
\usepackage[referable]{threeparttablex} % <--- for \note, \source

\usepackage{siunitx}            % new
\usepackage[skip=1ex,labelfont=bf,font=small]{caption}  % new options


\begin{document}
    \begin{table}[h]
\caption{Table title}
    \label{table:educ_dind_alt}
    \centering
    \sisetup{input-symbols = {( - )},
             table-space-text-post=***,
             }
\begin{threeparttable}
\begin{tabular}{@{}
        l*{5}{S[table-format=-1.2]}
                @{}}
    \toprule
    & {(1)} & {(2)} & {(3)} & {(4)} & {(5)}         \\
    \midrule
Variable
    & -0.08\tnote{***}
                & -0.03\tnote{*}
                            & -0.07\tnote{***}
                                        & -0.03\tnote{*}
                                                    & -0.03     \\
    & (0.02)    & (0.01)    & (0.02)    & (0.01)    & (0.02)    \\
    \midrule
Demographic Controls
    &           &   {X}     &   {X}     &   {X}     &   {X}     \\
State Year Trends
    &           &           &   {X}     &           &           \\
Education Year Trends
    &           &           &           &   {X}     &           \\
Alternative Weight
    &           &           &           &           &   {X}     \\
    \midrule
N   & {1.90e+09}& {1.90e+09}& {1.90e+09}& {1.90e+09}& {1.98e+07}\\
    \midrule[\heavyrulewidth]
\end{tabular}
    \begin{tablenotes}[flushleft, para]\footnotesize
\note
\item[*] $p<$0.1; \item[**] $p<0.05$; \item[***] $p<0.01$

more notes here
    \end{tablenotes}
\end{threeparttable}
    \end{table}
\end{document}

相关内容