长表中的相等列间距

长表中的相等列间距

有人知道如何在 longtable 中让列间距相等吗?我的代码附在下面。谢谢。Franz

\documentclass[12pt,a4paper]{article} \usepackage[latin1]{inputenc}
\usepackage{import} \usepackage{amsmath} \usepackage{amsfonts}
\usepackage{amssymb} %\usepackage{float} \usepackage{lscape} 
\usepackage{setspace} \usepackage{color} \usepackage{geometry}  
\geometry{a4paper,left=25.4mm,right=25.4mm,top=25.4mm,bottom=25.4mm} 
\usepackage{epsfig} \usepackage{epstopdf} \epstopdfsetup{update} 
\usepackage{booktabs} \usepackage{dcolumn} \usepackage{natbib} 
\usepackage{caption} \usepackage{subcaption} \usepackage{longtable}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\setlength{\tabcolsep}{1pt}

\renewcommand{\arraystretch}{.7}
\begin{scriptsize}
\begin{longtable}{l*{7}{c}}
\caption{Unconditional Quantile Wage Regressions: Non-performance paid, 2003-2004 \label{tab rifquantnw0304}}\\
    \hline\hline\endfirsthead\hline\endhead\hline\endfoot\endlastfoot
        &\multicolumn{1}{c}{RIF5}&\multicolumn{1}{c}{RIF10}&\multicolumn{1}{c}{RIF25}&\multicolumn{1}{r}{RIF50}&\multicolumn{1}{c}{RIF75}&\multicolumn{1}{c}{RIF90}&\multicolumn{1}{c}{RIF95}\\
        \hline
    Age                 &      0.0930\sym{**} &      0.0847\sym{***}&       0.127\sym{***}&       0.105\sym{***}      &      0.0275         &      -0.150\sym{***}&      -0.189\sym{***} \\
                        &      (3.14)         &      (4.42)         &      (7.52)         &      (7.04)               &      (1.78)       &     (-6.13)         &     (-5.77)         \\
    Age squared/1000    &      -1.283\sym{***}&      -1.100\sym{***}&      -1.326\sym{***}&      -1.081\sym{***}     &      -0.217         &       1.804\sym{***}&       2.217\sym{***} \\
                        &     (-3.64)         &     (-5.04)         &     (-7.78)         &     (-7.31)         &     (-1.39)       &      (6.95)         &      (6.07)         \\
    Female              &      -0.109\sym{**} &      -0.253\sym{***}&      -0.401\sym{***}&      -0.364\sym{***}     &           -0.227\sym{***}&      -0.186\sym{***}&      -0.129\sym{***} \\
                        &     (-2.66)         &     (-7.56)         &    (-13.53)         &    (-15.18)         &     (-9.87)       &     (-6.54)         &     (-3.98)         \\
    Married             &      0.0324         &     -0.0387         &    -0.00840         &      0.0631\sym{*}       &       0.147\sym{***}&       0.122\sym{***}&       0.118\sym{***}\\
                        &      (0.75)         &     (-1.41)         &     (-0.33)         &      (2.51)         &      (5.68)       &      (4.10)         &      (4.35)         \\
    Number of kids      &     -0.0501         &     -0.0390         &    -0.00465         &     0.00457         &     -0.0178       &    -0.00818         &      0.0195         \\
                        &     (-1.14)         &     (-1.31)         &     (-0.19)         &      (0.21)         &     (-0.75)       &     (-0.22)         &      (0.44)         \\
    Elementary school   &     -0.0545         &      -0.220\sym{**} &      -0.199\sym{***}&      -0.103\sym{**}      &     0.00754         &      0.0672\sym{*}  &       0.122\sym{**} \\
                        &     (-0.52)         &     (-3.06)         &     (-4.76)         &     (-3.19)         &      (0.23)       &      (2.01)         &      (2.93)         \\

    \hline
    Observations        &        5882         &        5882         &        5882         &        5882         &        5882         &        5882         &        5882         \\
    \hline\hline
    \end{longtable}
    \end{scriptsize}
\end{document}

答案1

(我意识到你的问题似乎是关于获得相等的宽度之间的列longtable。但是,由于列间空白由给出2\tabcolsep,因此列间宽度已经相等。因此,我将你的问题解释为关于获取列宽相等。

在本例中,由于您已经加载了dcolumn包,您可以通过以下方式实现您的目标:(i)定义一个名为 的新列类型d,对数字进行小数对齐;(ii)用 替换规范cd{3.6}这样做将确保d-type 列都具有相同的宽度;因此,相邻列之间小数点之间的水平距离是恒定的。

另外,由于您正在加载booktabs包,您可能还想用、等替换各种\hline指令\toprule\midrule

事实证明,无需进行\scriptsize,即,大约 30% 的字体大小线性减少,即可使表格适合。执行\footnotesize(大约 20% 的字体大小减少)就足够了。

在此处输入图片描述

\documentclass[12pt,a4paper]{article} 
\usepackage[latin1]{inputenc} 
%% I've commented out the packages that aren't needed for this MWE
%\usepackage{import} 
%\usepackage{amsmath} 
%\usepackage{amsfonts} 
%\usepackage{amssymb} 
%\usepackage{float} 
%\usepackage{lscape} 
%\usepackage{setspace} 
%\usepackage{color} 
\usepackage[margin=1in]{geometry} 
%\usepackage{epsfig} 
%\usepackage{epstopdf} 
%\epstopdfsetup{update} 
\usepackage{booktabs} 
\usepackage{dcolumn} 
\newcolumntype{d}[1]{D{.}{.}{#1}}
%\usepackage{natbib} 
%\usepackage{caption} 
%\usepackage{subcaption} 
\usepackage{longtable}
\setlength\LTcapwidth{\textwidth}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
%%\renewcommand{\arraystretch}{.7}
\begingroup
\setlength{\tabcolsep}{2pt} % default value: 6pt
\footnotesize
\begin{longtable}{@{} l *{7}{d{3.6}} @{}} % replace "c" with "d{3.6}"
\caption{Unconditional Quantile Wage Regressions: Non-performance paid, 2003--2004} 
\label{tab rifquantnw0304}\\
\toprule\endfirsthead
\midrule\endhead
\midrule\endfoot
\bottomrule\endlastfoot
&\mc{RIF5}& \mc{RIF10}& \mc{RIF25}& \mc{RIF50}& \mc{RIF75}& \mc{RIF90}& \mc{RIF95}\\
\midrule
Age                 &      0.0930\sym{**} &      0.0847\sym{***}&       0.127\sym{***}&       0.105\sym{***}      &      0.0275         &      -0.150\sym{***}&      -0.189\sym{***} \\
                    &      (3.14)         &      (4.42)         &      (7.52)         &      (7.04)               &      (1.78)       &     (-6.13)         &     (-5.77)         \\
Age squared/1000    &      -1.283\sym{***}&      -1.100\sym{***}&      -1.326\sym{***}&      -1.081\sym{***}     &      -0.217         &       1.804\sym{***}&       2.217\sym{***} \\
                    &     (-3.64)         &     (-5.04)         &     (-7.78)         &     (-7.31)         &     (-1.39)       &      (6.95)         &      (6.07)         \\
Female              &      -0.109\sym{**} &      -0.253\sym{***}&      -0.401\sym{***}&      -0.364\sym{***}     &           -0.227\sym{***}&      -0.186\sym{***}&      -0.129\sym{***} \\
                    &     (-2.66)         &     (-7.56)         &    (-13.53)         &    (-15.18)         &     (-9.87)       &     (-6.54)         &     (-3.98)         \\
Married             &      0.0324         &     -0.0387         &    -0.00840         &      0.0631\sym{*}       &       0.147\sym{***}&       0.122\sym{***}&       0.118\sym{***}\\
                    &      (0.75)         &     (-1.41)         &     (-0.33)         &      (2.51)         &      (5.68)       &      (4.10)         &      (4.35)         \\
Number of kids      &     -0.0501         &     -0.0390         &    -0.00465         &     0.00457         &     -0.0178       &    -0.00818         &      0.0195         \\
                    &     (-1.14)         &     (-1.31)         &     (-0.19)         &      (0.21)         &     (-0.75)       &     (-0.22)         &      (0.44)         \\
Elementary school   &     -0.0545         &      -0.220\sym{**} &      -0.199\sym{***}&      -0.103\sym{**}      &     0.00754         &      0.0672\sym{*}  &       0.122\sym{**} \\
                    &     (-0.52)         &     (-3.06)         &     (-4.76)         &     (-3.19)         &      (0.23)       &      (2.01)         &      (2.93)         \\

\midrule
Observations        & \mc{5882}         & \mc{5882}         & \mc{5882}         & \mc{5882}         & \mc{5882}         & \mc{5882}         & \mc{5882}         \\
\end{longtable}
\endgroup % end of scope of \footnotesize directive
\end{document}

相关内容