3

I am using multirows and my code is as follows:

\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}

My output is as follows:

my picture

As you can see, in Panel A, "All", "168", "162", and "6" are not aligned properly. Specifically, I would like "All" to be left aligned, while "168", "162", and "6" to be centered. Similarly in Panel B, I would like "All" to be left aligned while the numbers under the column "Quarters" to be centered. How can I do this using multirow?

1
  • Regarding to your reputation you should know how to provide MWE (minimal working example), so please, edit your question and add all what is missed that your code can be tested. Also you have some errors in code (illegal characters in array). Also, do you really need so many multicolumn{1}{..}{...} construction of cells?
    – Zarko
    Jul 16, 2016 at 5:03

2 Answers 2

1

After removing all cluters with \multicolumn{1}{c}{...} and \multicolumn{1}{l}{...} I obtain the following look-out of your table:

enter image description here

The format of last column is as it is shown in your image, which is not consistent with formatting of others columns with numbers. The code is (after guessing what you have in preamble of your document ...):

\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}
0

First of all, welcome to the website TrueTears.

From my experience multirow is not capable of a correct vertical alignment, if it spans multi-line cells. You can, however, adjust the alignment manually using the fixup-parameter:

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

Other possibilities for solving this problem are discussed in

"Centering mutirow text in a table whose cells contain several lines of text"

and

"How can I achieve proper vertical spacing for long blocks of text within a \multirow?".

1
  • I am not interested in vertical spacing, but rather horizontal spacing within the multirow.
    – TrueTears
    Jun 16, 2016 at 7:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .