表格中数字的对齐

表格中数字的对齐

我有下表:

\documentclass[12pt]{article}
\usepackage{rotating}
\usepackage{longtable}
\usepackage[labelfont=bf, labelsep=newline, justification=centering, textfont=it]{caption}
\usepackage{booktabs, makecell, siunitx}
\usepackage[referable,para]{threeparttablex}
\usepackage[scale=1,textheight=27cm, textwidth=15cm, margin=2.5cm]{geometry}
\usepackage{multirow}
\usepackage{interval}
\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***, 
table-number-alignment =center}
\newcommand*{\MyIndent}
{\hspace*{1.5cm}}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} 

    \begin{document}
    \begin{sidewaystable}[p] 
    \setlength{\tabcolsep}{9pt}
    \centering
    \normalsize
    \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
    \begin{threeparttable}
    \caption{Correlation Matrix \label{table3}}
    \begin{tabular}{l*{4}{d{2.5}}}
    \toprule \toprule
                                    & \multirow{2}[3]{*}{$(ln)y_{i,t}$}     &\multirow{2}[3]{*}{$PC_{i,t}$} &\multirow{2}[3]{*}{$PC^{2}_{i,t}$} & \mc{$(ln)s_{i,t}-$}         \\
                                            &                                                       &                                              &                                                    & \mc{$(ln)(n+\delta+g_{t}+g_{GLOB})_{i,t}$}   \\
    \midrule
    $(ln)y_{i,t}$               &\mc{1}                                                     &                                                           &                                                                   &                  \\[1.5ex]
    $PC_{i,t}$                      &0.441\sym{***}                                     &\mc{1}                                             &                                                                   &                  \\[1.5ex]
    $PC^{2}_{i,t}$          &0.504\sym{***}                                     &0.982\sym{***}                             &\mc{1}                                                     &                  \\[1.5ex]
    $(ln)s_{i,t}\,\ -$         &\multirow{2}{*}{0.591\sym{***}}&\multirow{2}{*}{0.324\sym{***}}&  \multirow{2}{*}{0.363\sym{***}}&    \multirow{2}{*}{1}         \\
    $(ln)(n+\delta+g_{t}+g_{GLOB})_{i,t}$&&&&\\
    \bottomrule\bottomrule
    \end{tabular}
    \begin{tablenotes}
    \footnotesize
          \item[]{\textit{Notes}: See Notes to Table 1. ``***'' denotes significance at 1\% level.}
          \end{tablenotes}
    \end{threeparttable}
    \end{sidewaystable}
    \end{document}

我尝试对齐最后一行的数字,但无法对齐。有什么办法吗?提前致谢

答案1

使用S列类型,并makecell简化您的代码:您将不需要multirow

\documentclass[12pt]{article}
\usepackage{rotating}
\usepackage{longtable}
\usepackage[labelfont=bf, labelsep=newline, justification=centering, textfont=it]{caption}
\usepackage{booktabs, makecell, siunitx}
\usepackage[referable,para]{threeparttablex}
\usepackage[scale=1,textheight=27cm, textwidth=15cm, margin=2.5cm]{geometry}
\usepackage{multirow}
\usepackage{interval}
\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***,
table-number-alignment=center}
\newcommand*{\MyIndent}
{\hspace*{1.5cm}}

\newcommand\mc[1]{\multicolumn{1}{c}{#1}}

\begin{document}
\begin{sidewaystable}[p]
\setlength{\tabcolsep}{9pt}
\centering
\normalsize
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{threeparttable}
\caption{Correlation Matrix \label{table3}}
\begin{tabular}{l*{4}{S}}%
\toprule \toprule
                            &{$ (ln)y_{i,t} $} &{$PC_{i,t}$} &{$PC^{2}_{i,t}$} & {\makecell{$(ln)s_{i,t}-$\\$(ln)(n+\delta+g_{t}+g_{GLOB})_{i,t}$}} \\
\midrule
$(ln)y_{i,t}$ & 1 & & & \\[1.5ex]
$PC_{i,t}$ &0.441\sym{***} & 1 & & \\[1.5ex]
$PC^{2}_{i,t}$ &0.504\sym{***} &0.982\sym{***} & 1 & \\[1.5ex]
\makecell[l]{$(ln)s_{i,t}\,\ -$\\$(ln)(n+\delta+g_{t}+g_{GLOB})_{i,t}$} & 0.591\sym{***} & 0.324\sym{***} & 0.363\sym{***} & 1 \\
\bottomrule\bottomrule
\end{tabular}
\begin{tablenotes}
\footnotesize\smallskip
  \item[]{\textit{Notes}: See Notes to Table 1. ``***'' denotes significance at 1\% level.}
  \end{tablenotes}
\end{threeparttable}
\end{sidewaystable}
\end{document} 

在此处输入图片描述

答案2

你不需要\multirow

\documentclass[12pt]{article}
\usepackage{rotating}
\usepackage{longtable}
\usepackage[labelfont=bf, labelsep=newline, justification=centering, textfont=it]{caption}
\usepackage{booktabs, makecell, siunitx}
\usepackage[referable,para]{threeparttablex}
\usepackage[scale=1,textheight=27cm, textwidth=15cm, margin=2.5cm]{geometry}
\usepackage{multirow}
\usepackage{interval}
\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***, 
table-number-alignment =center}
\newcommand*{\MyIndent}
{\hspace*{1.5cm}}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} 

\begin{document}
\begin{sidewaystable}[p] 
\setlength{\tabcolsep}{9pt}
\centering
\normalsize
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{threeparttable}
\caption{Correlation Matrix \label{table3}}
\begin{tabular}{c*{4}{d{3.6}}}
\toprule
& \mc{$(ln)y_{i,t}$} & \mc{$PC_{i,t}$} & \mc{$PC^{2}_{i,t}$} & 
  \mc{\begin{tabular}{@{}c@{}}
  $(ln)s_{i,t}-$ \\ $(ln)(n+\delta+g_{t}+g_{GLOB})_{i,t}$
  \end{tabular}} \\
\midrule
$(ln)y_{i,t}$   & \mc{1} &   &   &  \\
$PC_{i,t}$  &0.441\sym{***} &\mc{1} &   &  \\
$PC^{2}_{i,t}$  &0.504\sym{***} &0.982\sym{***} &\mc{1} &  \\
\begin{tabular}{@{}c@{}}
  $(ln)s_{i,t}\,\ -$ \\
  $(ln)(n+\delta+g_{t}+g_{GLOB})_{i,t}$
\end{tabular} &
  0.591\sym{***} & 0.324\sym{***} & 0.363\sym{***}& 1 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\footnotesize
  \item[]{\textit{Notes}: See Notes to Table 1. ``***'' denotes significance at 1\% level.}
  \end{tablenotes}
\end{threeparttable}
\end{sidewaystable}
\end{document}

在此处输入图片描述

答案3

问题似乎源于 的使用\multirow。因此,我\multirow从最后一行中删除了 s 并使用 来\pbox允许在第一列中换行:

\documentclass[12pt]{article}
\usepackage{rotating}
\usepackage{longtable}
\usepackage[labelfont=bf, labelsep=newline, justification=centering, textfont=it]{caption}
\usepackage{booktabs, makecell, siunitx}
\usepackage[referable,para]{threeparttablex}
\usepackage[scale=1,textheight=27cm, textwidth=15cm, margin=2.5cm]{geometry}
\usepackage{multirow}
\usepackage{interval}
\usepackage{pbox}
\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***, 
table-number-alignment =center}
\newcommand*{\MyIndent}
{\hspace*{1.5cm}}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} 

\begin{document}
\begin{sidewaystable}[p] 
\setlength{\tabcolsep}{9pt}
\centering
\normalsize
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{threeparttable}
\caption{Correlation Matrix \label{table3}}
\begin{tabular}{l*{4}{d{2.5}}}
\toprule \toprule
  & \multirow{2}[3]{*}{$(ln)y_{i,t}$} & \multirow{2}[3]{*}{$PC_{i,t}$} & \multirow{2}[3]{*}{$PC^{2}_{i,t}$} & \mc{$(ln)s_{i,t}-$} \\
  &                                   &                                &                                    & \mc{$(ln)(n+\delta+g_{t}+g_{GLOB})_{i,t}$} \\
\midrule
$(ln)y_{i,t}$ & \mc{1} & & & \\[1.5ex]
$PC_{i,t}$ & 0.441\sym{***} & \mc{1} & & \\[1.5ex]
$PC^{2}_{i,t}$ & 0.504\sym{***} & 0.982\sym{***} & \mc{1} & \\[1.5ex]
\pbox{\textwidth}{$(ln)s_{i,t}\,\ -$\\$(ln)(n+\delta+g_{t}+g_{GLOB})_{i,t}$} & 0.591\sym{***} & 0.324\sym{***} & 0.363\sym{***} & 1 \\
\bottomrule\bottomrule
\end{tabular}
\begin{tablenotes}
\footnotesize
      \item[]{\textit{Notes}: See Notes to Table 1. ``***'' denotes significance at 1\% level.}
      \end{tablenotes}
\end{threeparttable}
\end{sidewaystable}
\end{document}

请注意:如果您的文档中确实出现“参见表 1 的注释”的注释,则您应该将其更改为\ref

答案4

您应该尽量简化表格,可能如下所示。这样,\multirow一开始就不需要任何指令,甚至不需要以横向模式排版表格。

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage[labelfont=bf, labelsep=newline, 
   justification=centering, textfont=it]{caption}
\usepackage{booktabs}
\usepackage[para,flushleft]{threeparttable}
\usepackage[margin=2.5cm]{geometry}

\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}} 

\begin{document}
\begin{table}
\setlength{\tabcolsep}{9pt} % default: 6pt
\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{threeparttable}
\caption{Correlation Matrix} \label{table3}
\begin{tabular}{@{} l *{4}{d{2.5}} @{}}
\toprule 
& \mc{$\ln y_{i,t}$} 
& \mc{$PC_{i,t}$} 
& \mc{$PC^{2}_{i,t}$} 
& \mc{$Z$}   \\
\midrule
$\ln y_{i,t}$   &1  \\[1ex]
$PC_{i,t}$  &0.441\sym{***} &1 \\[1ex]
$PC^{2}_{i,t}$  &0.504\sym{***} &0.982\sym{***} &1  \\[1ex]
$Z$ &0.591\sym{***} &0.324\sym{***} &0.363\sym{***} & 1 \\
\bottomrule
\end{tabular}
$Z\equiv\ln s_{i,t}-\ln (n+\delta+g_{t}+g^{}_{GLOB}{)}_{i,t}$

\smallskip
``***'' denotes significance at 1\% level

\smallskip
\begin{tablenotes}
\item[]\textit{Notes}: See Notes to Table 1.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}

相关内容