修复第一列的对齐问题

修复第一列的对齐问题

我重新排列了表格,使所有数字在小数点处对齐。到目前为止,这种方法也有效。但是,第一列变得非常难看:

在此处输入图片描述

我想将第一列左对齐,并将表格的其余部分与小数点对齐。

我的表格的第一列应如下所示:

在此处输入图片描述

我认为错误就出在这个命令上:

\begin{tabularx}{\linewidth}{>{$}r<{$}@{}>{$}l<{$} | S | *{4}{S} @{}}

我该如何指定此命令以便显示我想要的表格?提前谢谢!

这是我的表的代码:

\documentclass[]{article}
\usepackage[margin=1in]{geometry}
\usepackage{floatrow} \floatsetup[figure]{capposition=top} \floatsetup[table]{capposition=top} \usepackage{setspace}
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{tabu}
\usepackage[normalem]{ulem}
\usepackage[utf8]{inputenc}
\usepackage{array}
\floatsetup[figure]{capposition=top}
\floatsetup[table]{capposition=top}
\usepackage{siunitx}
\newcolumntype{d}{S[table-format=2.1]}
\usepackage{booktabs, makecell, multirow, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage[referable]{threeparttablex}
\NewExpandableDocumentCommand \mcc{mO{C}m}{\multicolumn{#1}{#2}{#3}}

\begin{table}[!h]  
\caption{\label{tab:table_13}CAAR (-2;+2) of target firms according to transaction forms and deal characteristics} 
\sisetup{table-format=2.1,
             table-space-text-post={***}
             }
    \setcellgapes{2pt}
    \makegapedcells
    \setlength\tabcolsep{3pt}
    \begin{tabularx}{\linewidth}{>{$}r<{$}@{}>{$}l<{$} | S | *{4}{S} @{}}
\Xhline{1.2pt} 
\mcc{2}[c|]{\makecell[t]{Description}} & \mcc{1}[c|]{\makecell[t]{All\\transaction\\forms}} & \mcc{1}{\makecell[t]{Acquisition Of\\ Partial Interest}} & \mcc{1}{\makecell[t]{Acquisition Of\\ Majority Assets}} & \mcc{1}{\makecell[t]{Acquisition Of \\ Remaining Interest}} & \mcc{1}{\makecell[t]{Merger}}\\
\Xhline{0.8pt}
\addlinespace[0.3em]  
\hspace{0em}{\textbf{Deal Attitude}}&\\ 
\hspace{1em} Friendly & 13.1 * * * & 5.7 * * * & 11.2 * * * & 13.4 * * * & 20.3 * * *\\ 
\hspace{1em} Hostile & 15.7 * * * & 5.1 & 24.8 & 12.4 & 17.1 * * *\\ 
\hspace{1em}Neutral & 5.0 * * * & 4.7 * * * & 5.1 & 17.6 & 7.6\\ 
\hspace{1em}No Applicable & -1.5 & -1.0 & -8.3 & NA & 0.5\\ 
\hspace{1em}Unsolicited & 16.3 * * * & 12.0 * & 12.7 * * & 82.4 & 16.4 * * *\\  
\hspace{0em}{\textbf{Location}}&\\ 
\hspace{1em}cross-border & 13.9 * * * & 6.7 * * * & 22.9 * * * & 14.8 * * * & 21.9 * * *\\ 
\hspace{1em}domestic & 11.7 * * * & 4.6 * * * & 10.1 * * * & 13.1 * * * & 18.5 * * *\\  
\hspace{0em}{\textbf{Industry}}&\\ 
\hspace{1em}cross industry & 11.9 * * * & 4.8 * * * & 10.7 * * * & 15.7 * * * & 19.9 * * *\\ 
\hspace{1em}same industry & 14.4 * * * & 8.5 * * * & 12.5 * * * & 9.7 * * * & 19.7 * * *\\  \hspace{0em}{\textbf{Financial}}&\\ 
\hspace{1em}Financial & 10.0 * * * & 3.3 * & 5.1 & 15.2 * * * & 16.1 * * *\\ 
\hspace{1em}Non-Financial & 12.8 * * * & 5.7 * * * & 11.7 * * * & 13.5 * * * & 20.3 * * *\\
\Xhline{1.2pt}
\end{tabularx} \end{table}

\end{document}

答案1

如果使用tabular*而不是则会更容易tabularx

不需要\multirow,也不需要“间隙单元”。

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{array}
\usepackage{siunitx}

\begin{document}

\begin{table}[htp]

% local command for split cells
\newcommand{\splitcell}[1]{{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}}

\sisetup{
  table-format=-1.2,
  table-space-text-post={***}
}
\setlength{\tabcolsep}{0pt} % let TeX do the work

\caption{\label{tab:table_13}CAAR (-2;+2) of target firms according to
  transaction forms and deal characteristics} 

\begin{tabular*}{\linewidth}{
  @{\quad}
  l
  @{\extracolsep{\fill}}
  S[table-format=-1.1]
  S[table-format=-1.1]
  S[table-format=-1.1]
  S[table-format=2.1]
  S[table-format=2.1]
}
\toprule
\multicolumn{1}{l}{\quad Description} &
{\smash{\splitcell{All\\transaction\\forms}}} &
\multicolumn{3}{c}{Acquisition of} &
{Merger}
\\
\cmidrule{3-5}
&&
\splitcell{Partial \\ Interest} &
\splitcell{Majority \\ Assets} &
\splitcell{Remaining \\ Interest} &
\\
\midrule
\multicolumn{6}{@{}l}{\textbf{Deal Attitude}} \\
  Friendly       & 13.1 *** &  5.7 *** & 11.2 *** & 13.4 *** & 20.3 *** \\
  Hostile        & 15.7 *** &  5.1     & 24.8     & 12.4     & 17.1 *** \\
  Neutral        &  5.0 *** &  4.7 *** &  5.1     & 17.6     &  7.6     \\
  No Applicable  & -1.5     & -1.0     & -8.3     & {NA}     &  0.5     \\
  Unsolicited    & 16.3 *** & 12.0 *   & 12.7 **  & 82.4     & 16.4 *** \\
\midrule
\multicolumn{6}{@{}l}{\textbf{Location}} \\
  cross-border   & 13.9 *** &  6.7 *** & 22.9 *** & 14.8 *** & 21.9 *** \\
  domestic       & 11.7 *** &  4.6 *** & 10.1 *** & 13.1 *** & 18.5 *** \\
\midrule
\multicolumn{6}{@{}l}{\textbf{Industry}} \\
  cross industry & 11.9 *** &  4.8 *** & 10.7 *** & 15.7 *** & 19.9 *** \\
  same industry  & 14.4 *** &  8.5 *** & 12.5 *** &  9.7 *** & 19.7 *** \\
\midrule
\multicolumn{6}{@{}l}{\textbf{Financial}} \\
  Financial      & 10.0 *** &  3.3 *   &  5.1     & 15.2 *** & 16.1 *** \\
  Non-Financial  & 12.8 *** &  5.7 *** & 11.7 *** & 13.5 *** & 20.3 *** \\
\bottomrule
\end{tabular*}

\end{table}

\end{document}

在此处输入图片描述

输入也更简单:部分标题使用\multicolumn忽略 1em 填充的字体排版。\smash拆分后的单元格深度为零。

答案2

在此处输入图片描述

\documentclass[]{article}
\usepackage[margin=1in]{geometry}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{makecell}
\renewcommand\theadalign{tc}
\renewcommand{\theadfont}{\normalsize}

\newcommand{\rowhead}[1]{\multicolumn{1}{@{}l}{\bfseries #1}}
\begin{document}
\begin{table}
\centering
\caption{\label{tab:table_13}CAAR (-2;+2) of target firms according to transaction forms and deal characteristics} 
\sisetup{table-format=-2.1,
             table-space-text-post={***}
             }
    \begin{tabular}{@{\hspace{1em}}l  *{5}{S} @{}}
\toprule
\multirow{3.5}{*}{\thead{Description}} 
& {\multirow{3.5}{*}{\thead{All\\transaction\\forms}}} 
& \multicolumn{3}{c}{Acquisition Of}
& {\multirow{3.5}{*}{\thead{Merger}}}\\
\cmidrule{3-5}
&&{\thead{Partial\\ Interest}} 
& {\thead{Majority\\ Assets}} 
& {\thead{Remaining\\ Interest}} 
\\
\midrule 
\rowhead{Deal Attitude}\\ 
Friendly       & 13.1 * * * & 5.7 * * * & 11.2 * * * & 13.4 * * * & 20.3 * * * \\ 
Hostile        & 15.7 * * * & 5.1       & 24.8       & 12.4       & 17.1 * * * \\ 
Neutral        & 5.0 * * *  & 4.7 * * * & 5.1        & 17.6       & 7.6        \\ 
No Applicable  & -1.5       & -1.0      & -8.3       & NA         & 0.5        \\ 
Unsolicited    & 16.3 * * * & 12.0 *    & 12.7 * *   & 82.4       & 16.4 * * * \\  
\addlinespace
\rowhead{Location}\\ 
cross-border   & 13.9 * * * & 6.7 * * * & 22.9 * * * & 14.8 * * * & 21.9 * * * \\ 
domestic       & 11.7 * * * & 4.6 * * * & 10.1 * * * & 13.1 * * * & 18.5 * * * \\ 
\addlinespace 
\rowhead{Industry}\\ 
cross industry & 11.9 * * * & 4.8 * * * & 10.7 * * * & 15.7 * * * & 19.9 * * * \\ 
same industry  & 14.4 * * * & 8.5 * * * & 12.5 * * * & 9.7 * * *  & 19.7 * * * \\ 
\addlinespace 
\rowhead{Financial}\\ 
Financial      & 10.0 * * * & 3.3 *     & 5.1        & 15.2 * * * & 16.1 * * * \\ 
Non-Financial  & 12.8 * * * & 5.7 * * * & 11.7 * * * & 13.5 * * * & 20.3 * * * \\
\bottomrule
\end{tabular} 
\end{table}

\end{document}

相关内容