需要帮助使用 dcolumn

需要帮助使用 dcolumn

请帮忙!我需要对齐我的表格,现在看起来有点乱。我尝试使用 dcolumn 包,但无法让它工作。任何帮助都非常感谢!

梅威瑟:

\documentclass[twocolumn]{article}

\usepackage[T1]{fontenc}
\usepackage{newtxtext}
\usepackage{amsmath,geometry,siunitx,booktabs, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcommand\mC[1]{\multicolumn{1}{C@{}}{#1}} 
\sisetup{group-separator={,}, group-minimum-digits=4}
\usepackage[skip=1ex]{caption}
\captionsetup[table]{font=small, labelfont=bf, singlelinecheck=no}
\usepackage{makecell}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}
\usepackage{textcomp}
\usepackage{graphicx}
\raggedbottom
\usepackage{rotating}
\usepackage[referable]{threeparttablex}
\usepackage{upquote}
\usepackage{balance}
\usepackage{wasysym}
\usepackage{footmisc}
\usepackage{float}
\floatstyle{boxed} 
\restylefloat{figure}

%ZARKO:
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage{newtxtext}
\usepackage{textcomp}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}
\usepackage{siunitx}
\sisetup{group-integer-digits,% in case of rounding decimals to three digits can be omitted
         group-separator={,},
         group-minimum-digits=4
         }
\usepackage[skip=1ex]{caption}
\captionsetup[table]{font=small, labelfont=bf, singlelinecheck=no}
%END ZARKO

\title{\LARGE \bf ECON 425 Term Paper}

\author{}

\begin{document}

\begin{table*}[!htbp]
\caption{Estimates of pay-performance sensitivity.}
\label{tab:table1}
OLS regressions of CEO salary and CEO total compensation on change in shareholder wealth. Standard errors in parentheses.

   \medskip
    \setlength\tabcolsep{4pt}
    \small
    \makegapedcells
\begin{tabularx}{\textwidth}{@{}L lll@{}}
    \toprule
\thead[l]{Dependent\\ variable}
            &  \thead[l]{CEO\\
                         salary\\
                         (eq. \ref{eqn:first})}


                                            & \thead[l]{CEO total\\
                                            compensation\\
                                            (eq. \ref{eqn:second})}

& \thead[l]{CEO salary \\ (not controlling \\for industry) (eq. \ref{eqn:third})}

\\

Return (\%)       &  $\underset{(0.083))}{-0.320}$        &   $\underset{(1.545)}{2.213}$        &  $\underset{(0.082)}{-0.303}$        
\\
Volume & $\underset{(0.000)}{0.002}$ & $\underset{(0.003)}{0.069}$ & $\underset{(0.000)}{0.002}$
\\    
Return*Volume   & $\underset{(0.000)}{0.000}$      &  $\underset{(0.000)}{0.000}$   &   $\underset{(0.000)}{0.000}$                          \\
Log (bonus)
                &  $\underset{(1.38)}{-5.269}$   & --- & $\underset{(1.365)}{-6.431}$          \\

Stock Awards    & $\underset{(0.000)}{0.036}$ & --- &  $\underset{(0.000)}{0.036}$                   \\
Option Awards    &  $\underset{(0.000)}{0.023}$        & --- &  $\underset{(0.001)}{0.027}$                      \\
Other Compensation & $\underset{(0.000)}{0.028}$ & --- & $\underset{(0.003)}{0.027}$
    \\
Age &  $\underset{(4.567)}{33.387}$ &  $\underset{(84.768)}{913.016}$ &  $\underset{(4.575)}{39.237}$
    \\
Age\textsuperscript{2} & $\underset{(0.039)}{-0.217}$ &  $\underset{(0.733)}{-7.435}$ &  $\underset{(0.039)}{-0.267}$
    \\
Male & $\underset{(18.079)}{-2.601}$ & $\underset{(337.631)}{-465.612}$ &  $\underset{(17.615)}{-31.349}$
    \\
Outdoors &  $\underset{(77.902)}{-173.761}$ & $\underset{(1453.675)}{-4268.128}$
    \\
Mining & $\underset{(26.792)}{-178.289}$ & $\underset{(499.369)}{-972.327}$
    \\
Utilities & $\underset{(34.906)}{-199.853}$  &  $\underset{(651.127)}{-4217.222 }$
    \\
Construction & $\underset{(33.259)}{-102.424}$ & $\underset{(620.558)}{-3572.244}$
    \\
Wholesale &  $\underset{(28.814)}{-193.954}$ &  $\underset{(537.382)}{-3827.542}$
    \\
Information &  $\underset{(24.494)}{-218.414}$ &  $\underset{(456.968)}{-618.642}$
    \\
Finance &  $\underset{(23.320)}{-160.005}$ & $\underset{(434.591)}{-3078.595 }$
    \\
Real estate &  $\underset{(25.248)}{-303.096}$ & $\underset{(470.966)}{-3410.482}$
    \\
Professional & $\underset{(27.486)}{-238.323}$ & $\underset{(512.813)}{-3776.246}$
    \\
Waste  & $\underset{(31.766)}{-186.965}$& $\underset{(592.813)}{-3365.898}$
    \\
Education & $\underset{(50.956)}{-287.113}$ & $\underset{(950.712)}{-5770.548}$
    \\
Healthcare & $\underset{(32.953)}{-153.385}$ & $\underset{(615.121)}{-2123.471}$
    \\
Arts & $\underset{(56.622)}{178.082}$ & $\underset{(1056.786)}{-2303.748}$
    \\
Food & $\underset{(31.091)}{-34.24}$ & $\underset{(579.849)}{-2656.446}$
    \\
Other & $\underset{(61.642)}{-109.691}$ & $\underset{(1150.511)}{-3786.196}$
    \\
Manufacturing & $\underset{(22.394)}{-193.729}$ & $\underset{(417.698)}{-2540.859}$
    \\
Transportation & $\underset{(29.509)}{-313.349}$ & $\underset{(551.778)}{-3678.069}$
    \\
Retail &  $\underset{(25.756)}{-80.145}$ & $\underset{(480.656)}{-2295.232}$
    \\
    \bottomrule
\end{tabularx}

\smallskip
$^{*}p<0.10$, $^{**}p<0.05$, $^{***}p<0.01$.
    \end{table*}

\end{document}

目前的情况如下:

在此处输入图片描述

答案1

dcolumn包要求它要操作的单元格只包含一个数字 — — 更准确地说,只包含一个带有小数点的数字。单元格内容会自动置于数学模式;添加$ ... $分隔符是不合适的,也\underset{...}{...}不会起作用。

如果要继续使用这种dcolumn方法,您必须大幅重写所有三个数据列。您还很可能必须将表格拆分成两页,因为您要报告的回归系数数量惊人。

修改后的表格的前几行可能如下所示:

在此处输入图片描述

\documentclass[twocolumn]{article}

\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath} % Times Roman text and math fonts
\usepackage{amsmath,geometry,booktabs}

\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcommand\mC[1]{\multicolumn{1}{C@{}}{#1}} 
\newcommand\mc[1]{\multicolumn{1}{c@{}}{#1}}

\usepackage{siunitx}
\sisetup{group-separator={,}, group-minimum-digits=4}

\usepackage[skip=1ex]{caption}
\captionsetup[table]{font=small, labelfont=bf, singlelinecheck=no}

\usepackage{makecell}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}

\usepackage{textcomp}
\usepackage{graphicx}
\raggedbottom
\usepackage{rotating}
\usepackage[referable]{threeparttablex}
\usepackage{upquote,balance,wasysym,footmisc}

\usepackage{float}
\floatstyle{boxed} 
\restylefloat{figure}

%ZARKO:
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage{newtxtext}
\usepackage{textcomp}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}
\usepackage{siunitx}
\sisetup{group-integer-digits,% in case of rounding decimals to three digits can be omitted
         group-separator={,},
         group-minimum-digits=4
         }
\usepackage[skip=1ex]{caption}
\captionsetup[table]{font=small, labelfont=bf, singlelinecheck=no}
%END ZARKO

%% MICO
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}

\begin{document}

\begin{table*}[!htbp]
\caption{Estimates of pay-performance sensitivity.}
\label{tab:table1}
\small
OLS regressions of CEO salary and CEO total compensation on change in shareholder wealth. Standard errors in parentheses.

\medskip
\makegapedcells
\begin{tabularx}{\textwidth}{@{} L *{3}{d{2.4}} @{}}
\toprule
Dependent variable
& \mc{\thead[l]{CEO\\ salary\\ (eq. \ref{eqn:first})}}
& \mc{\thead[l]{CEO total\\ compensation\\ (eq. \ref{eqn:second})}}
& \mc{\thead[l]{CEO salary (not\\ controlling for\\ industry) (eq. \ref{eqn:third})}}
\\
\midrule
Return (\%)   & -0.320  & 2.213   & -0.303  \\
              & (0.083) & (1.545) & (0.082) \\
Volume        & 0.002   & 0.069   & 0.002   \\    
              & (0.000) & (0.003) & (0.000) \\
Return\,$*$Volume & 0.000   & 0.000   & 0.000   \\
              & (0.000) & (0.000) & (0.000) \\
\dots \\
\bottomrule
\end{tabularx}

\smallskip
$^{*}p<0.10$, $^{**}p<0.05$, $^{***}p<0.01$.
\end{table*}

\end{document}

相关内容