如何更好地格式化宽表并删除列之间的多余间距?

如何更好地格式化宽表并删除列之间的多余间距?

我排版了一个宽表,如下所示。请忽略列值中的重复项:在此处输入图片描述

  • 我想要浮点值与小数点对齐。
  • 我还想将“估算报告”中的值放在左侧,而不是像现在这样放在中心。

生成该表所用的代码如下:

\documentclass[12pt,a4paper,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[inner=1in,outer=1in,tmargin=1in,bmargin=1in]{geometry}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{bm}
\usepackage{caption}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{rotating} % rotate the table
\usepackage{pdflscape}% rotate the page
\usepackage{pdfpages}
\usepackage{multicol}

\usepackage[ group-separator={,} ]{siunitx}
\sisetup{
    output-exponent-marker = \text{\hspace{1pt}e},
    exponent-product={},
    retain-explicit-plus,
    input-open-uncertainty  = ,
    input-close-uncertainty = ,
    table-align-text-pre    = false,
    table-align-text-post = false,
    round-mode=places,
    round-precision=3,
    table-space-text-pre    = (,
    table-space-text-post   = ),
}
\newcolumntype{D}{@{}S[table-format =-3.3e-1]@{}}

\begin{document}
\thispagestyle{empty}
\begin{landscape}
\begin{table}
%\begin{table}[p]
\centering
\begin{minipage}{\linewidth}
\caption{***TABLE CAPTION***} 
\label{***TABLE LABEL***}%
\resizebox{\textwidth}{!}{
\begin{tabular}{l|DDD|DDD|DDD|DDD}
    \multicolumn{13}{@{}l}{\begin{tabular}[l]{l}\Large \textbf{Parameter Estimates}\end{tabular}}\\
    \toprule
    \multirow{2}{*}{\textbf{Parameter}}  & \multicolumn{3}{c|}{\textbf{Model~1}} & \multicolumn{3}{c|}{\textbf{Model~2}} & \multicolumn{3}{c|}{\textbf{Model~3}} & \multicolumn{3}{c}{\textbf{Model~4}}          \\
    \cmidrule(l){2-13}
      & {\textbf{Value}} & {\textbf{Std err}} & {\textbf{t-test}} & {\textbf{Value}} & {\textbf{Std err}} & {\textbf{t-test}} & {\textbf{Value}} & {\textbf{Std err}} & {\textbf{t-test}} & {\textbf{Value}} & {\textbf{Std err}} & {\textbf{t-test}}          \\
    \midrule
    $ASC_C$ &  -1.560 & 0.678 & -2.301 & -1.560 & 0.678 & -2.301 & -1.560 & 0.678 & -2.301 & -1.560 & 0.678 & -2.301    \\  
$BTOTIME$ &  -0.024 & 9.020e-03 & -2.676 & -0.024 & 9.020e-03 & -2.676 & -0.024 & 9.020e-03 & -2.676 & -0.024 & 9.020e-03 & -2.676    \\  
$BOVTTDist$ &  -0.307 & 0.081 & -3.798 & -0.307 & 0.081 & -3.798 & -0.307 & 0.081 & -3.798 & -0.307 & 0.081 & -3.798    \\  
$BCOST$ &  -0.843 & 0.121 & -6.973 & -0.843 & 0.121 & -6.973 & -0.843 & 0.121 & -6.973 & -0.843 & 0.121 & -6.973    \\  
$BMale$ &  -0.496 & 0.390 & -1.271 & -0.496 & 0.390 & -1.271 & -0.496 & 0.390 & -1.271 & -0.496 & 0.390 & -1.271    \\  
$BNumVeh$ &  0.639 & 0.253 & 2.521 & 0.639 & 0.253 & 2.521 & 0.639 & 0.253 & 2.521 & 0.639 & 0.253 & 2.521    \\  
$BTRANSFER$ &  -0.541 & 0.462 & -1.170 & -0.541 & 0.462 & -1.170 & -0.541 & 0.462 & -1.170 & -0.541 & 0.462 & -1.170    \\
    \midrule

    \multicolumn{13}{@{}l}{\begin{tabular}[l]{l}\end{tabular}}\\
    \multicolumn{13}{@{}l}{\begin{tabular}[l]{l}\Large \textbf{Estimation Report}\end{tabular}}\\

    \midrule
    Sample Size &  \multicolumn{3}{D|}{543} & \multicolumn{3}{D|}{543} & \multicolumn{3}{D|}{543} & \multicolumn{3}{D}{543}    \\  
Null LL: [$\mathcal{L}(0)$] &  \multicolumn{3}{D|}{-376.379} & \multicolumn{3}{D|}{-376.379} & \multicolumn{3}{D|}{-376.379} & \multicolumn{3}{D}{-376.379}    \\  
Constants-only LL: [$\mathcal{L}(C)$] &  \multicolumn{3}{D|}{-216.197} & \multicolumn{3}{D|}{-216.197} & \multicolumn{3}{D|}{-216.197} & \multicolumn{3}{D}{-216.197}    \\  
\midrule
\# Estimated Parameters &  \multicolumn{3}{D|}{7} & \multicolumn{3}{D|}{7} & \multicolumn{3}{D|}{7} & \multicolumn{3}{D}{7}    \\  
Final LL: [$\mathcal{L}(\hat{\beta})$] &  \multicolumn{3}{D|}{-103.524} & \multicolumn{3}{D|}{-103.524} & \multicolumn{3}{D|}{-103.524} & \multicolumn{3}{D}{-103.524}    \\  
$\rho^2$ &  \multicolumn{3}{D|}{0.725} & \multicolumn{3}{D|}{0.725} & \multicolumn{3}{D|}{0.725} & \multicolumn{3}{D}{0.725}    \\  
$\rho_c^2$ &  \multicolumn{3}{D|}{0.521} & \multicolumn{3}{D|}{0.521} & \multicolumn{3}{D|}{0.521} & \multicolumn{3}{D}{0.521}    \\  
$\overline{\rho}^2$ &  \multicolumn{3}{D|}{0.706} & \multicolumn{3}{D|}{0.706} & \multicolumn{3}{D|}{0.706} & \multicolumn{3}{D}{0.706}    \\  
$\overline{\rho_c}^2$ &  \multicolumn{3}{D|}{0.491} & \multicolumn{3}{D|}{0.491} & \multicolumn{3}{D|}{0.491} & \multicolumn{3}{D}{0.491}    \\  
AIC &  \multicolumn{3}{D|}{221.049} & \multicolumn{3}{D|}{221.049} & \multicolumn{3}{D|}{221.049} & \multicolumn{3}{D}{221.049}    \\  
AICc &  \multicolumn{3}{D|}{221.258} & \multicolumn{3}{D|}{221.258} & \multicolumn{3}{D|}{221.258} & \multicolumn{3}{D}{221.258}    \\  
BIC &  \multicolumn{3}{D|}{251.129} & \multicolumn{3}{D|}{251.129} & \multicolumn{3}{D|}{251.129} & \multicolumn{3}{D}{251.129}    \\  
Success(Y=1, N=0)? &  \multicolumn{3}{D|}{1} & \multicolumn{3}{D|}{1} & \multicolumn{3}{D|}{1} & \multicolumn{3}{D}{1}    \\
\bottomrule

\end{tabular}
}
\end{minipage}
\end{table}%
\end{landscape}

\end{document}

我想改进此表的格式,并删除列之间的额外间距。请提供您的意见。

答案1

在此处输入图片描述

  • 不使用\resizebox,而是减小字体大小\footnotesize
  • S每列采用列
  • table-space-text-pre已删除table-space-text-post
  • 而不是tabulars 用一个共同的tabular*
  • 删除了除表头之外的\multicolumn所有
  • 列间距的确定留给 LaTeX
\documentclass[12pt,a4paper,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[inner=1in,outer=1in,tmargin=1in,bmargin=1in]{geometry}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{bm}
\usepackage{caption}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{rotating} % rotate the table
\usepackage{pdflscape}% rotate the page
\usepackage{pdfpages}
\usepackage{multicol}

\usepackage[ group-separator={,} ]{siunitx}
\sisetup{
    output-exponent-marker = \text{\hspace{1pt}e},
    exponent-product={},
    retain-explicit-plus,
    input-open-uncertainty  = ,
    input-close-uncertainty = ,
    table-align-text-pre    = false,
    table-align-text-post = false,
    round-mode=places,
    round-precision=3,
%    table-space-text-pre    = (,
%    table-space-text-post   = ),
}
%\newcolumntype{D}{@{}S[table-format =-3.3e-1]@{}}

\begin{document}
\thispagestyle{empty}
\begin{landscape}
\begin{table}
    \setlength\tabcolsep{0pt}
    \footnotesize
\caption{***TABLE CAPTION***}
\label{***TABLE LABEL***}%
\begin{tabular*}{\linewidth}
                {@{\extracolsep{\fill}} l *{4}{S[table-format=-3.3]
                                               S[table-format=1.3e-1]
                                               S[table-format=-1.3]}
                }
\multicolumn{13}{@{}l}{\Large\textbf{Parameter Estimates}}  \\
    \midrule[\heavyrulewidth]
\multirow{2.3}{*}{\textbf{Parameter}}  
    &   \multicolumn{3}{c}{\textbf{Model~1}} 
        &   \multicolumn{3}{c}{\textbf{Model~2}} 
            & \multicolumn{3}{c}{\textbf{Model~3}} 
                & \multicolumn{3}{c}{\textbf{Model~4}}                  \\
    \cmidrule(l){2-4}
    \cmidrule(l){5-7}
    \cmidrule(l){8-10}
    \cmidrule(l){11-13}
    & {\textbf{Value}} & {\textbf{Std err}} & {\textbf{t-test}} 
    & {\textbf{Value}} & {\textbf{Std err}} & {\textbf{t-test}} 
    & {\textbf{Value}} & {\textbf{Std err}} & {\textbf{t-test}} 
    & {\textbf{Value}} & {\textbf{Std err}} & {\textbf{t-test}}         \\
    \midrule
ASC\textsubscript{C}
    &   -1.560  & 0.678     & -2.301 & -1.560 & 0.678       & -2.301 
    &   -1.560  & 0.678     & -2.301 & -1.560 & 0.678       & -2.301    \\
BTOTIME
    &  -0.024 & 9.020e-03   & -2.676 & -0.024 & 9.020e-03   & -2.676 
    &  -0.024 & 9.020e-03   & -2.676 & -0.024 & 9.020e-03   & -2.676    \\
BOVTTDist
    &  -0.307 & 0.081       & -3.798 & -0.307 & 0.081       & -3.798 
    &  -0.307 & 0.081       & -3.798 & -0.307 & 0.081       & -3.798    \\
BCOST
    &  -0.843 & 0.121       & -6.973 & -0.843 & 0.121       & -6.973 
    &  -0.843 & 0.121       & -6.973 & -0.843 & 0.121       & -6.973    \\
BMale
    &  -0.496 & 0.390       & -1.271 & -0.496 & 0.390       & -1.271 
    &  -0.496 & 0.390       & -1.271 & -0.496 & 0.390       & -1.271    \\
BNumVeh
    &  0.639  & 0.253       &  2.521 &  0.639 & 0.253       &  2.521 
    &  0.639  & 0.253       &  2.521 &  0.639 & 0.253       &  2.521    \\
BTRANSFER
    &  -0.541 & 0.462       & -1.170 & -0.541 & 0.462       & -1.170 
    &  -0.541 & 0.462       & -1.170 & -0.541 & 0.462       & -1.170    \\
    \midrule    \\

\multicolumn{13}{@{}l}{\Large\textbf{Estimation Report}}                \\
    \midrule
Sample Size 
    &  543      &   &   & 543       &   &   & 543       &   &   & 543       &   &   \\
Null LL: [$\mathcal{L}(0)$] 
    & -376.379  &   &   & -376.379  &   &   & -376.379  &   &   & -376.379  &   &   \\
Constants-only LL: [$\mathcal{L}(C)$] 
    & -216.197  &   &   & -216.197  &   &   & -216.197  &   &   & -216.197  &   &   \\
\midrule
\# Estimated Parameters 
    & 7         &   &   & 7         &   &   & 7         &   &   & 7         &   &   \\
Final LL: [$\mathcal{L}(\hat{\beta})$] 
    & -103.524  &   &   & -103.524  &   &   & -103.524  &   &   & -103.524  &   &   \\
$\rho^2$ 
    &  0.725    &   &   & 0.725     &   &   & 0.725     &   &   & 0.725     &   &   \\
$\rho_c^2$      
    & 0.521     &   &   & 0.521     &   &   & 0.521     &   &   & 0.521     &   &   \\
$\overline{\rho}^2$ 
    & 0.706     &   &   & 0.706     &   &   & 0.706     &   &   & 0.706     &   &   \\
$\overline{\rho_c}^2$ 
    & 0.491     &   &   &  0.491    &   &   & 0.491     &   &   & 0.491     &   &   \\
AIC & 221.049   &   &   & 221.049   &   &   & 221.049   &   &   & 221.049   &   &   \\
AICc 
    & 221.258   &   &   & 221.258   &   &   & 221.258   &   &   & 221.258   &   &   \\
BIC & 251.129   &   &   & 251.129   &   &   & 251.129   &   &   & 251.129   &   &   \\
Success(Y=1, N=0)? 
    & 1         &   &   & 1         &   &   & 1         &   &   & 1         &   &   \\
    \bottomrule
\end{tabular*}
    \end{table}
\end{landscape}

相关内容