多行左对齐和居中

多行左对齐和居中

我正在使用多行,我的代码如下:

\begin{table}[H]   
\footnotesize
\setlength\tabcolsep{2pt}
\begin{center}
  \caption{\\ \fontsize{10pt}{12pt}\selectfont  \normalfont insert title
}
\label{table8}

\noindent\makebox[\textwidth]{
\begin{tabular}{@{}l *{12}{D{.}{.}{4}}@{}}
\toprule
\multicolumn{5}{l}{Panel A: name of panel} & &  \multicolumn{2}{c}{titles} & & & & & \\
\cmidrule(l){3-12} 

\multicolumn{1}{l}{Period} & \multicolumn{1}{c}{Months} & \multicolumn{1}{c}{1} & \multicolumn{1}{c}{2} & \multicolumn{1}{c}{3} & \multicolumn{1}{c}{4} & \multicolumn{1}{c}{5} & \multicolumn{1}{c}{6} & \multicolumn{1}{c}{7} & \multicolumn{1}{c}{8} & \multicolumn{1}{c}{9} & \multicolumn{1}{c}{10} & \multicolumn{1}{c}{$1-10$} \\
\midrule

\multirow{2}{*}{All} & \multirow{2}{*}{168} & \multicolumn{1}{c}{1.20} & \multicolumn{1}{c}{0.74} & \multicolumn{1}{c}{0.61} & \multicolumn{1}{c}{0.57} & \multicolumn{1}{c}{0.50} & \multicolumn{1}{c}{0.48} & \multicolumn{1}{c}{0.45} & \multicolumn{1}{c}{0.41} & \multicolumn{1}{c}{0.45} & \multicolumn{1}{c}{0.32} & \multicolumn{1}{c}{0.87$^{**}$} \\
& & \multicolumn{1}{c}{(2.64)} & \multicolumn{1}{c}{(2.53)} & \multicolumn{1}{c}{(2.69)} & \multicolumn{1}{c}{(3.11)} & \multicolumn{1}{c}{(3.26)} & \multicolumn{1}{c}{(3.52)} & \multicolumn{1}{c}{(3.78)} & \multicolumn{1}{c}{(3.86)} & \multicolumn{1}{c}{(3.98)} & \multicolumn{1}{c}{(2.60)} & \multicolumn{1}{c}{(2.03)} \\


\multicolumn{1}{l}{Non-crisis} & \multirow{2}{*}{162} & \multicolumn{1}{c}{1.58} & \multicolumn{1}{c}{0.99} & \multicolumn{1}{c}{0.80} & \multicolumn{1}{c}{0.73} & \multicolumn{1}{c}{0.65} & \multicolumn{1}{c}{0.61} & \multicolumn{1}{c}{0.56} & \multicolumn{1}{c}{0.52} & \multicolumn{1}{c}{0.54} & \multicolumn{1}{c}{0.38} & \multicolumn{1}{c}{1.19$^{***}$} \\
\multicolumn{1}{l}{periods} & & \multicolumn{1}{c}{(3.97)} & \multicolumn{1}{c}{(3.89)} & \multicolumn{1}{c}{(4.12)} & \multicolumn{1}{c}{(4.83)} & \multicolumn{1}{c}{(5.44)} & \multicolumn{1}{c}{(5.97)} & \multicolumn{1}{c}{(6.17)} & \multicolumn{1}{c}{(7.11)} & \multicolumn{1}{c}{(6.31)} & \multicolumn{1}{c}{(3.42)} & \multicolumn{1}{c}{(3.02)} \\


\multicolumn{1}{l}{Crisis} & \multirow{2}{*}{6} & \multicolumn{1}{c}{-9.12} & \multicolumn{1}{c}{-5.94} & \multicolumn{1}{c}{-4.50} & \multicolumn{1}{c}{-3.83} & \multicolumn{1}{c}{-3.49} & \multicolumn{1}{c}{-3.04} & \multicolumn{1}{c}{-2.46} & \multicolumn{1}{c}{-2.52} & \multicolumn{1}{c}{-2.12} & \multicolumn{1}{c}{-1.23} & \multicolumn{1}{c}{-7.89$^{***}$} \\
\multicolumn{1}{l}{periods} & & \multicolumn{1}{c}{(-5.13)} & \multicolumn{1}{c}{(-4.93)} & \multicolumn{1}{c}{(-3.77)} & \multicolumn{1}{c}{(-4.50)} & \multicolumn{1}{c}{(-3.97)} & \multicolumn{1}{c}{(-3.13)} & \multicolumn{1}{c}{(-2.55)} & \multicolumn{1}{c}{(-2.75)} & \multicolumn{1}{c}{(-2.04)} & \multicolumn{1}{c}{(-1.22)} & \multicolumn{1}{c}{(-8.34)} \\
\midrule


\multicolumn{5}{l}{Panel B: name of panel} & &  \multicolumn{2}{c}{titles} & & & & & \\

\cmidrule(l){3-12} 

\multicolumn{1}{l}{Period} & \multicolumn{1}{c}{Quarters} & \multicolumn{1}{c}{1} & \multicolumn{1}{c}{2} & \multicolumn{1}{c}{3} & \multicolumn{1}{c}{4} & \multicolumn{1}{c}{5} & \multicolumn{1}{c}{6} & \multicolumn{1}{c}{7} & \multicolumn{1}{c}{8} & \multicolumn{1}{c}{9} & \multicolumn{1}{c}{10} & \multicolumn{1}{c}{$1-10$} \\
\midrule



\multirow{2}{*}{All} & \multirow{2}{*}{56} & \multicolumn{1}{c}{3.83} & \multicolumn{1}{c}{2.26} & \multicolumn{1}{c}{1.99} & \multicolumn{1}{c}{1.87} & \multicolumn{1}{c}{1.74} & \multicolumn{1}{c}{1.50} & \multicolumn{1}{c}{1.38} & \multicolumn{1}{c}{1.35} & \multicolumn{1}{c}{1.34} & \multicolumn{1}{c}{1.15} & \multicolumn{1}{c}{2.68$^{**}$} \\

& &  \multicolumn{1}{c}{(2.60)} & \multicolumn{1}{c}{(2.23)} & \multicolumn{1}{c}{(2.50)} & \multicolumn{1}{c}{(2.86)} & \multicolumn{1}{c}{(2.83)} & \multicolumn{1}{c}{(2.95)} & \multicolumn{1}{c}{(2.95)} & \multicolumn{1}{c}{(3.55)} & \multicolumn{1}{c}{(4.13)} & \multicolumn{1}{c}{(3.24)} & \multicolumn{1}{c}{(1.99)} \\




\multicolumn{1}{l}{Non-crisis} & \multirow{2}{*}{53} & \multicolumn{1}{c}{5.02} & \multicolumn{1}{c}{3.10} & \multicolumn{1}{c}{2.67} & \multicolumn{1}{c}{2.48} & \multicolumn{1}{c}{2.29} & \multicolumn{1}{c}{1.99} & \multicolumn{1}{c}{1.88} & \multicolumn{1}{c}{1.78} & \multicolumn{1}{c}{1.70} & \multicolumn{1}{c}{1.44} & \multicolumn{1}{c}{3.58$^{***}$} \\

\multicolumn{1}{l}{periods} & & \multicolumn{1}{c}{(3.95)} & \multicolumn{1}{c}{(3.62)} & \multicolumn{1}{c}{(4.12)} & \multicolumn{1}{c}{(5.00)} & \multicolumn{1}{c}{(4.83)} & \multicolumn{1}{c}{(5.66)} & \multicolumn{1}{c}{(6.29)} & \multicolumn{1}{c}{(8.37)} & \multicolumn{1}{c}{(8.72)} & \multicolumn{1}{c}{(4.95)} & \multicolumn{1}{c}{(2.81)} \\




\multicolumn{1}{l}{Crisis} & \multirow{2}{*}{2} & \multicolumn{1}{c}{-23.99} & \multicolumn{1}{c}{-15.44} & \multicolumn{1}{c}{-12.23} & \multicolumn{1}{c}{-10.68} & \multicolumn{1}{c}{-9.45} & \multicolumn{1}{c}{-8.89} & \multicolumn{1}{c}{-8.16} & \multicolumn{1}{c}{-7.24} & \multicolumn{1}{c}{-6.19} & \multicolumn{1}{c}{-4.16} & \multicolumn{1}{c}{-19.84$^{***}$} \\


\multicolumn{1}{l}{periods} & & \multicolumn{1}{c}{(-10.32)} & \multicolumn{1}{c}{(-10.99)} & \multicolumn{1}{c}{(-9.04)} & \multicolumn{1}{c}{(-8.81)} & \multicolumn{1}{c}{(-5.63)} & \multicolumn{1}{c}{(-4.62)} & \multicolumn{1}{c}{(-4.64)} & \multicolumn{1}{c}{(-4.02)} & \multicolumn{1}{c}{(-3.35)} & \multicolumn{1}{c}{(-2.08)} & \multicolumn{1}{c}{(-60.95)} \\

\bottomrule
\end{tabular}}
\end{center}
\end{table}

我的输出如下:

我的照片

如您所见,在面板 A 中,“全部”、“168”、“162”和“6”未正确对齐。具体来说,我希望“全部”左对齐,而“168”、“162”和“6”居中。同样,在面板 B 中,我希望“全部”左对齐,而“季度”列下的数字居中。如何使用多行来实现此目的?

答案1

在删除了所有杂乱内容后\multicolumn{1}{c}{...}\multicolumn{1}{l}{...}我获得了以下表格:

在此处输入图片描述

最后一列的格式如图片所示,与其他带数字的列的格式不一致。代码如下(猜出文档序言中的内容后...):

\documentclass{article}
\usepackage{dcolumn} 
\usepackage{booktabs,multirow}
\usepackage{caption}

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

\begin{document}
\begin{table}
    \footnotesize
    \setlength\tabcolsep{2pt}
\centering
  \caption{insert title}
\label{table8}

    \noindent\makebox[\textwidth]{
\begin{tabular}{@{}l c *{10}{D{.}{.}{3}}c@{}}
    \toprule
\multicolumn{5}{l}{Panel A: name of panel} 
    & &  \multicolumn{2}{c}{titles} & & & & & \\
    \cmidrule(l){3-12}
Period & \mc{Months} & \mc{1} & \mc{2} & \mc{3} & \mc{4} & \mc{5} 
            & \mc{6} & \mc{7} & \mc{8} & \mc{9} & \mc{10} & \mc{$1-10$} \\
\midrule
\multirow{2}{*}{All} & \multirow{2}{*}{168} 
    & 1.20 & 0.74 & 0.61 & 0.57 & 0.50 & 0.48 & 0.45 & 0.41 & 0.45 & 0.32 &     0.87$^{**}$
    \\
& & (2.64) & (2.53) & (2.69) & (3.11) & (3.26) & (3.52) & (3.78) & (3.86) & (3.98) & (2.60) & (2.03) \\

Non-crisis & \multirow{2}{*}{162}
    & 1.58 & 0.99 & 0.80 & 0.73 & 0.65 & 0.61 & 0.56 & 0.52 & 0.54 & 0.38 & 1.19$^{***}$ \\
periods &
    & (3.97) & (3.89) & (4.12) & (4.83) & (5.44) & (5.97) & (6.17) & (7.11) & (6.31) & (3.42) & (3.02) \\

Crisis & \multirow{2}{*}{6}
    & -9.12 & -5.94 & -4.50 & -3.83 & -3.49 & -3.04 & -2.46 & -2.52 & -2.12 & -1.23 & -7.89$^{***}$ \\
periods &
    & (-5.13) & (-4.93) & (-3.77) & (-4.50) & (-3.97) & (-3.13) & (-2.55) & (-2.75) & (-2.04) & (-1.22) & (-8.34) \\
\midrule

\multicolumn{5}{l}{Panel B: name of panel}
    & &  \multicolumn{2}{c}{titles} & & & & & \\
    \cmidrule(l){3-12}
Period & \mc{Months} & \mc{1} & \mc{2} & \mc{3} & \mc{4} & \mc{5}
            & \mc{6} & \mc{7} & \mc{8} & \mc{9} & \mc{10} & \mc{$1-10$} \\
\midrule
\multirow{2}{*}{All} & \multirow{2}{*}{56}
    & 3.83 & 2.26 & 1.99 & 1.87 & 1.74 & 1.50 & 1.38 & 1.35 & 1.34 & 1.15 & 2.68$^{**}$ \\
& &  (2.60) & (2.23) & (2.50) & (2.86) & (2.83) & (2.95) & (2.95) & (3.55) & (4.13) & (3.24) & (1.99) \\

\multicolumn{1}{l}{Non-crisis} & \multirow{2}{*}{53}
    & 5.02 & 3.10 & 2.67 & 2.48 & 2.29 & 1.99 & 1.88 & 1.78 & 1.70 & 1.44 & 3.58$^{***}$ \\

\multicolumn{1}{l}{periods} &
    & (3.95) & (3.62) & (4.12) & (5.00) & (4.83) & (5.66) & (6.29) & (8.37) & (8.72) & (4.95) & (2.81) \\

\multicolumn{1}{l}{Crisis} & \multirow{2}{*}{2}
    & -23.99 & -15.44 & -12.23 & -10.68 & -9.45 & -8.89 & -8.16 & -7.24 & -6.19 & -4.16 & -19.84$^{***}$    \\

\multicolumn{1}{l}{periods} &
    & (-10.32) & (-10.99) & (-9.04) & (-8.81) & (-5.63) & (-4.62) & (-4.64) & (-4.02) & (-3.35) & (-2.08) & (-60.95) \\
\bottomrule
\end{tabular}}
    \end{table}
\end{document}

答案2

首先,欢迎来到 TrueTears 网站。

根据我的经验multirow,如果跨越多行单元格,则无法正确进行垂直对齐。但是,您可以使用 -parameter 手动调整对齐方式fixup

% \multirow{nrows}[bigstruts]{width}[fixup]{text}
\multirow{-10}{*}[3em]{\cellcolor{yellow}\begin{sideways}TEST\end{sideways}}

解决该问题的其他可能性在

在单元格包含多行文本的表格中将多行文本居中

我怎样才能为 \multirow 内的长文本块实现适当的垂直间距?“。

相关内容