使用 \multicolumn{}{p{}} 设置最后一列不合适

使用 \multicolumn{}{p{}} 设置最后一列不合适

我想使用命令在表格下方添加表格注释\multicolumn

明确地说,我不想使用这种threeparttable风格。

如您所见,第 6 列比其他列留出了更多空间。我认为这是由于:

\multicolumn{7}{p{\linewidth}}{\footnotesize Note: The regressions reported in column (3) and (6)
    control for the \textit{ward}. Perfect prediction of the variables \textit{adress}
    and \textit{household\_key} was proofed. Further information are given at the notes
    in Table \ref{table:6}.}

需要进行哪些调整才能使第 6 列和第 5 列之间的间距与第 1 列和第 2 列之间的间距相同?

\documentclass[a4paper,12pt]{article}
\usepackage{fancyhdr}
\usepackage[a4paper,lmargin={2.5cm},rmargin={2.5cm},
tmargin={2cm},bmargin = {2cm}]{geometry}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{float}
\usepackage{eurosym}



\usepackage[titletoc,title]{appendix}
\usepackage[nottoc,notlot,notlof]{tocbibind}

\usepackage{hyperref}
\linespread{1.25}
\floatstyle{plaintop}
\restylefloat{table}
\begin{table}[H] 
    \begin{center}
    \caption{Information Source of a Loan\label{table:7}}

    \resizebox{\textwidth}{!}{
    \begin{tabular}{@{\extracolsep{5pt}}lcccccc}
    \\[-1.8ex]\hline 
    \hline \\[-1.8ex] 
     & \multicolumn{6}{c}{\textit{Dependent variable:}} \\ 
    \cline{2-7} 
    \\[-1.8ex] & \multicolumn{3}{c}{runner75} & \multicolumn{3}{c}{runner} \\ 
     & \multicolumn{3}{c}{Transaction Accounts} & \multicolumn{3}{c}{Term Deposit Accounts} \\ 
    \\[-1.8ex] & (1) & (2) & (3) & (4) & (5) & (6)\\ 
    \hline \\[-1.8ex] 
    ln\_accountage      & $-0.0060^{***}$ & $-0.0060^{***}$ & $-0.0060^{***}$ & $-0.0158^{***}$ & $-0.0158^{***}$ & $-0.0129^{***}$ \\
                        & $(0.0014)$      & $(0.0014)$      & $(0.0014)$      & $(0.0022)$      & $(0.0022)$      & $(0.0029)$      \\
    opening\_balance    & $0.0001^{***}$  & $0.0001^{***}$  & $0.0001^{***}$  & $0.0033^{**}$   & $0.0033^{**}$   & $0.0042^{**}$   \\
                        & $(0.0000)$      & $(0.0000)$      & $(0.0000)$      & $(0.0011)$      & $(0.0011)$      & $(0.0015)$      \\
    avg\_withdraw\_chng & $0.1143^{*}$    & $0.1143^{*}$    & $0.1264^{*}$    &                 &                 &                 \\
                        & $(0.0561)$      & $(0.0561)$      & $(0.0539)$      &                 &                 &                 \\
    avg\_deposit\_chng  & $-0.0011$       & $-0.0011$       & $-0.0011$       &                 &                 &                 \\
                        & $(0.0012)$      & $(0.0012)$      & $(0.0012)$      &                 &                 &                 \\
    avg\_transaction    & $0.0000$        & $0.0000$        & $0.0000$        &                 &                 &                 \\
                        & $(0.0000)$      & $(0.0000)$      & $(0.0000)$      &                 &                 &                 \\
    minority\_dummy     & $0.0063^{*}$    & $0.0063^{*}$    & $0.0073$        & $0.0077$        & $0.0077$        & $0.0055$        \\
                        & $(0.0029)$      & $(0.0029)$      & $(0.0039)$      & $(0.0059)$      & $(0.0059)$      & $(0.0083)$      \\
    above\_insurance    & $0.3288^{***}$  & $0.3288^{***}$  & $0.3627^{***}$  & $0.0193$        & $0.0193$        & $0.0243$        \\
                        & $(0.0444)$      & $(0.0444)$      & $(0.0492)$      & $(0.0142)$      & $(0.0142)$      & $(0.0188)$      \\
    loanlink\_current   & $-0.0134^{***}$ & $-0.0134^{***}$ & $-0.0126^{***}$ & $-0.0347^{***}$ & $-0.0347^{***}$ & $-0.0401^{***}$ \\
                        & $(0.0032)$      & $(0.0032)$      & $(0.0035)$      & $(0.0059)$      & $(0.0059)$      & $(0.0058)$      \\
    loanlink\_before    & $-0.0132^{***}$ & $-0.0132^{***}$ & $-0.0129^{***}$ & $-0.0281^{**}$  & $-0.0281^{**}$  & $-0.0334^{***}$ \\
                        & $(0.0030)$      & $(0.0030)$      & $(0.0030)$      & $(0.0089)$      & $(0.0089)$      & $(0.0086)$      \\
    travel\_costs       &                 &                 & $0.0002$        &                 &                 & $-0.0072$       \\
                        &                 &                 & $(0.0011)$      &                 &                 & $(0.0037)$      \\
    loanlink\_after     &                 &                 & $-0.0097$       &                 &                 & $-0.0087$       \\
                        &                 &                 & $(0.0067)$      &                 &                 & $(0.0189)$      \\
    ln\_maturity        &                 &                 &                 & $-0.0204^{***}$ & $-0.0204^{***}$ & $-0.0229^{***}$ \\
                        &                 &                 &                 & $(0.0015)$      & $(0.0015)$      & $(0.0020)$      \\
    \hline
    AIC                 & 2143.9911       & 2143.9911       & 1878.1146       & 1679.2417       & 1679.2417       & 1329.3163       \\
    BIC                 & 2216.7627       & 2216.7627       & 2203.4264       & 1730.6668       & 1730.6668       & 1559.7964       \\
    Log Likelihood      & -1061.9956      & -1061.9956      & -893.0573       & -831.6208       & -831.6208       & -626.6582       \\
    Deviance            & 2123.9911       & 2123.9911       & 1786.1146       & 1663.2417       & 1663.2417       & 1253.3163       \\
    Num. obs.           & 10691           & 10691           & 8708            & 4574            & 4574            & 3182            \\
    \hline

    \multicolumn{7}{l}{\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}} \\
    \multicolumn{7}{p{\linewidth}}{\footnotesize Note: The regressions reported in column (3) and (6) control for the \textit{ward}. Perfect prediction of the variables \textit{adress} and \textit{household\_key} was proofed. Further information are given at the notes in Table \ref{table:6}.}
    \end{tabular}
    }
    \end{center}
    \end{table} 
    \end {document}

答案1

一些评论:

  • 没有必要将最后的“注释”段落作为材料的一部分tabular。事实上,正是\multicolumn{7}{p{\linewidth}{...}指令——以及@{\extracolsep{5pt}}环境标题中的tabular——导致了最后一列(即第 7 列)的不理想对齐。通过将“注释”材料放在外部表格,当然,\end{table}声明。

  • 请考虑一下数字信息的对齐方式。c我不会使用通用列类型将材料放在第 2 列到第 7 列中,而是使用一种方法对小数点进行对齐,例如使用包dcolumn及其D列类型。这样做还可以去掉$表体中的大约 210 个符号。(顺便说一句,是否有必要显示AIC、BIC、对数似然和偏差的小数位数是多少?一位小数可能同样有效 - 甚至可能更好...)

  • 考虑加载包并使用其规则绘制宏、和 ,而不是\hline\cline(偶尔会\\[-1.8ex]进行一些尴尬的间距调整)。间距改进包括booktabs\toprule\midrule\cmidrule戏剧性

  • 纸张尺寸为A4,水平边距为2.5cm,实际上无需将tabular材料放在语句中\resizebox以使表格材料适合文本块。另请参阅下一个要点。

  • 最后,我建议你使用tabular*环境 而不是tabular环境。将环境的宽度设置tabular*\textwidth,使用@{\extracolsep{\fill}}而不是@{\extracolsep{5pt}},让 LaTeX 处理计算列间空白量的问题。

在此处输入图片描述

\documentclass[12pt,a4paper]{article}
\usepackage[hmargin=2.5cm,vmargin=2cm]{geometry}
\usepackage{caption,booktabs,dcolumn}
\newcolumntype{d}[1]{D..{#1}}
%% Two handy shortcut macros:
  \newcommand{\mc}[1]{\multicolumn{1}{c}{#1}}
  \newcommand{\G}[1]{\multicolumn{1}{@{}d{5.4}@{}}{#1}}

\begin{document}
\begin{table}
\setlength\tabcolsep{1pt} % default value: 6pt
\caption{Information Source of a Loan\label{table:7}}
\begin{tabular*}{\textwidth}{@{} l 
                            @{\extracolsep{\fill}} %% let LaTeX determine best col sep
                            *{6}{d{2.6}} @{}}
\toprule
 & \multicolumn{6}{c@{}}{Dependent variable} \\ 
\cmidrule{2-7} 
 & \multicolumn{3}{c}{runner75} 
 & \multicolumn{3}{c@{}}{runner} \\ 
 & \multicolumn{3}{c}{Transaction Accounts} 
 & \multicolumn{3}{c@{}}{Term Deposit Accounts} \\ 
\cmidrule(lr){2-4} \cmidrule(l){5-7}
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} & \mc{(5)} & \multicolumn{1}{c@{}}{(6)}\\ 
\midrule  
ln\_accountage & -0.0060^{***} & -0.0060^{***} & -0.0060^{***} & -0.0158^{***} & -0.0158^{***} & -0.0129^{***} \\
  & (0.0014) & (0.0014) & (0.0014) & (0.0022) & (0.0022) & (0.0029) \\
opening\_balance  & 0.0001^{***} & 0.0001^{***} & 0.0001^{***} & 0.0033^{**} & 0.0033^{**} & 0.0042^{**} \\
  & (0.0000) & (0.0000) & (0.0000) & (0.0011) & (0.0011) & (0.0015) \\
avg\_withdraw\_chng & 0.1143^{*}  & 0.1143^{*}  & 0.1264^{*}  & & & \\
  & (0.0561) & (0.0561) & (0.0539) & & & \\
avg\_deposit\_chng & -0.0011 & -0.0011 & -0.0011 & & & \\
  & (0.0012) & (0.0012) & (0.0012) & & & \\
avg\_transaction  & 0.0000 & 0.0000 & 0.0000 & & & \\
  & (0.0000) & (0.0000) & (0.0000) & & & \\
minority\_dummy   & 0.0063^{*}  & 0.0063^{*}  & 0.0073 & 0.0077 & 0.0077 & 0.0055 \\
  & (0.0029) & (0.0029) & (0.0039) & (0.0059) & (0.0059) & (0.0083) \\
above\_insurance  & 0.3288^{***} & 0.3288^{***} & 0.3627^{***} & 0.0193 & 0.0193 & 0.0243 \\
  & (0.0444) & (0.0444) & (0.0492) & (0.0142) & (0.0142) & (0.0188) \\
loanlink\_current & -0.0134^{***} & -0.0134^{***} & -0.0126^{***} & -0.0347^{***} & -0.0347^{***} & -0.0401^{***} \\
  & (0.0032) & (0.0032) & (0.0035) & (0.0059) & (0.0059) & (0.0058) \\
loanlink\_before  & -0.0132^{***} & -0.0132^{***} & -0.0129^{***} & -0.0281^{**} & -0.0281^{**} & -0.0334^{***} \\
  & (0.0030) & (0.0030) & (0.0030) & (0.0089) & (0.0089) & (0.0086) \\
travel\_costs & & & 0.0002 & & & -0.0072  \\
  & & & (0.0011) & & & (0.0037) \\
loanlink\_after   & & & -0.0097 & & & -0.0087  \\
  & & & (0.0067) & & & (0.0189) \\
ln\_maturity & & & & -0.0204^{***} & -0.0204^{***} & -0.0229^{***} \\
  & & & & (0.0015) & (0.0015) & (0.0020) \\
\midrule
AIC & \G{2143.9911} & \G{2143.9911} & \G{1878.1146} & \G{1679.2417} & \G{1679.2417} & \G{1329.3163}  \\
BIC & \G{2216.7627} & \G{2216.7627} & \G{2203.4264} & \G{1730.6668} & \G{1730.6668} & \G{1559.7964}  \\
Log Likelihood & \G{-1061.9956} & \G{-1061.9956} & \G{-893.0573} & \G{-831.6208} & \G{-831.6208} & \G{-626.6582}  \\
Deviance & \G{2123.9911} & \G{2123.9911} & \G{1786.1146} & \G{1663.2417} & \G{1663.2417} & \G{1253.3163}  \\
Num.\ obs. & \mc{10691} & \mc{10691} & \mc{8708} & \mc{4574} & \mc{4574} & \mc{3182} \\
\midrule
\multicolumn{7}{@{}l}{\small $^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$} \\[1ex]
\end{tabular*}
Note: The regressions reported in column (3) and (6) control for the \textit{ward}. 
  Perfect prediction of the variables \textit{adress} and \textit{household\_key} was 
  proofed. Further information is given in the notes of Table \ref{table:6}.
\end{table} 
\end{document}

相关内容