3

I am trying to create a table consisting of three other subtables. I have tried it with two versions (see e.g Alignment Problem in Table environment). There are three problems: 1) The Columns of the subtabtles without header are "shifted". 2) For the last subtabtles there appears wide space. 3) I´d would like to put the caption of the first subtables after the headline (like the other subtables).

1) The version with dcolumn:

\begin{table}[ht!]
\setlength\tabcolsep{0.1pt}  % default value: 6.0pt
\caption{Post-Announcement Returns to Earnings Surprise Portfolios}
\label{tab:PortfolioReturns}

\begin{subtable}{\textwidth}
\caption*{\textbf{Panel A:} Portfolio Ranks formed according to SUE1} 
\label{tab:PortfolioSUE1}
\begin{tabular*}{\textwidth}%
  { @{\extracolsep{\fill}} l *{1}{d{4.0}} *{1}{d{2.5}} 
      *{2}{d{4.0}} *{2}{d{2.5}} @{} }
\toprule
 & \multicolumn{1}{c}{N} & \multicolumn{1}{c}{mean} & \multicolumn{2}{c}{N} & \multicolumn{2}{c}{mean} \\
\cmidrule{4-5} \cmidrule{6-7}
Surprise Portfolio & \mc{N} & \mc{mean} & \mc{CASC} & \mc{BHAR} & \mc{CASC} & \multicolumn{1}{r@{}}{BHAR} \\
\midrule
1 & 1389 & -0.09759 & 1226 & 1350 & -0.00029 & -0.00566 \\
2 & 1348 & -0.01259 & 1181 & 1331 & 0.00065 & -0.00232 \\
3 & 1390 & -0.00447 & 1213 & 1367 & 0.00050 & -0.00404 \\
4 & 1376 & -0.00184 & 1164 & 1360 & 0.00009 & -0.00140 \\
5 & 1402 & 0.00046 & 1222 & 1383 & 0.00025 & 0.00189 \\
6 & 1331 & 0.00180 & 1175 & 1322 & 0.00025 & 0.00667 \\
7 & 1349 & 0.00368 & 1182 & 1333 & 0.00019 & 0.00675 \\
8 & 1327 & 0.00622 & 1193 & 1318 & 0.00031 & 0.00557 \\
9 & 1303 & 0.01191 & 1137 & 1283 & 0.00002 & 0.01829 \\
10 & 1335 & 0.08969 & 1183 & 1300 & -0.00044 & 0.03208 \\
\multicolumn{5}{l}{Hedge return (Portfolio 10 - Portfolio 1)} & -0.00015 & 0.03774\\
\bottomrule
\end{tabular*}
\end{subtable}
\bigskip
\begin{subtable}{\textwidth}
\caption*{\textbf{Panel B:} Portfolio Ranks formed according to SUE2} 
\label{tab:PortfolioSUE2}
\begin{tabular*}{\textwidth}%
  { @{\extracolsep{\fill}} l *{1}{d{4.0}} *{1}{d{2.5}} 
      *{2}{d{4.0}} *{2}{d{2.5}} @{} }
1 & 1409 & -0.06690 & 1235 & 1372 & -0.00041 & -0.00714 \\
2 & 1324 & -0.01011 & 1164 & 1306 & 0.00086 & -0.00222 \\
3 & 1382 & -0.00383 & 1182 & 1363 & 0.00049 & -0.00555 \\
4 & 1419 & -0.00136 & 1207 & 1399 & 0.00014 & -0.00317 \\
5 & 1338 & 0.00063 & 1181 & 1324 & 0.00012 & 0.00219 \\
6 & 1370 & 0.00177 & 1223 & 1353 & 0.00024 & 0.01033 \\
7 & 1351 & 0.00323 & 1197 & 1336 & 0.00006 & 0.00835 \\
8 & 1329 & 0.00545 & 1180 & 1318 & 0.00015 & 0.00528 \\
9 & 1348 & 0.01014 & 1177 & 1331 & 0.00015 & 0.01316 \\
10 & 1300 & 0.06622 & 1140 & 1263 & 0.00002 & 0.03416 \\
\multicolumn{5}{l}{Hedge return (Portfolio 10 - Portfolio 1)} & 0.00043 & 0.04130\\
\bottomrule
\end{tabular*}
\end{subtable}
\bigskip
\begin{subtable}{\textwidth}
\begin{threeparttable}
\caption*{\textbf{Panel C:} Portfolio Ranks formed according to SUE3} 
\label{tab:PortfolioSUE3}
\small
\begin{tabular*}{\textwidth}%
  { @{\extracolsep{\fill}} l *{1}{d{4.0}} *{1}{d{2.5}} 
      *{2}{d{4.0}} *{2}{d{2.5}} @{} }
1 & 1231 & -0.02934 & 1084 & 1213 & 0.00196 & -0.02531 \\
2 & 1232 & -0.00173 & 1052 & 1223 & 0.00043 & -0.01476 \\
3 & 1200 & -0.00032 & 1046 & 1196 & 0.00030 & -0.01422 \\
4 & 1252 & 0.00028 & 1110 & 1245 & 0.00030 & 0.00016 \\
5 & 1181 & 0.00058 & 1028 & 1177 & 0.00021 & 0.00516 \\
6 & 1220 & 0.00097 & 1060 & 1215 & 0.00007 & 0.00587 \\
7 & 1195 & 0.00152 & 1050 & 1186 & 0.00020 & 0.00998 \\
8 & 1193 & 0.00228 & 1046 & 1185 & -0.00037 & 0.02167 \\
9 & 1249 & 0.00386 & 1099 & 1246 & 0.00042 & 0.02336 \\
10 & 1171 & 0.01378 & 1065 & 1162 & -0.00089 & 0.04821 \\
\multicolumn{5}{l}{Hedge return (Portfolio 10 - Portfolio 1)} & -0.00285 & 0.07352\\
\bottomrule
\end{tabular*}

\begin{tablenotes}
\item[a] A subtable-specific footnote
\end{tablenotes}

\end{threeparttable}
\end{subtable}

\end{table}

and the siunitx version:

\begin{table}[ht!]
\setlength\tabcolsep{0.1pt}  % default value: 6.0pt
\caption{Post-Announcement Returns to Earnings Surprise Portfolios}
\label{tab:PortfolioReturns}
\begin{subtable}{\textwidth}
\caption*{\textbf{Panel A:} Portfolio Ranks formed according to SUE1} 
\label{tab:PortfolioSUE1}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l 
  S[table-format=4.0]
  S[table-format=-1.5]
  *{2}{S[table-format=4.0]}
  *{2}{S[table-format=-1.5]}
  @{}
}
\toprule
 & & & \multicolumn{2}{c}{N} & \multicolumn{2}{c}{mean} \\
\cmidrule{4-5} \cmidrule{6-7}
Surprise Portfolio & {N} & {mean} & {CASC} & {BHAR} & {CASC} & {BHAR} \\
\midrule
1 & 1389 & -0.09759 & 1226 & 1350 & -0.00029 & -0.00566 \\
2 & 1348 & -0.01259 & 1181 & 1331 & 0.00065 & -0.00232 \\
3 & 1390 & -0.00447 & 1213 & 1367 & 0.00050 & -0.00404 \\
4 & 1376 & -0.00184 & 1164 & 1360 & 0.00009 & -0.00140 \\
5 & 1402 & 0.00046 & 1222 & 1383 & 0.00025 & 0.00189 \\
6 & 1331 & 0.00180 & 1175 & 1322 & 0.00025 & 0.00667 \\
7 & 1349 & 0.00368 & 1182 & 1333 & 0.00019 & 0.00675 \\
8 & 1327 & 0.00622 & 1193 & 1318 & 0.00031 & 0.00557 \\
9 & 1303 & 0.01191 & 1137 & 1283 & 0.00002 & 0.01829 \\
10 & 1335 & 0.08969 & 1183 & 1300 & -0.00044 & 0.03208 \\
\multicolumn{5}{l}{Hedge return (Portfolio 10 - Portfolio 1)} & -0.00015 & 0.03774\\
\midrule
\end{tabular*}
\end{subtable}
\bigskip
\begin{subtable}{\textwidth}
\caption*{\textbf{Panel B:} Portfolio Ranks formed according to SUE2} 
\label{tab:PortfolioSUE2}
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l 
  S[table-format=4.0]
  S[table-format=-1.5]
  *{2}{S[table-format=4.0]}
  *{2}{S[table-format=-1.5]}
  @{}
}
1 & 1409 & -0.06690 & 1235 & 1372 & -0.00041 & -0.00714 \\
2 & 1324 & -0.01011 & 1164 & 1306 & 0.00086 & -0.00222 \\
3 & 1382 & -0.00383 & 1182 & 1363 & 0.00049 & -0.00555 \\
4 & 1419 & -0.00136 & 1207 & 1399 & 0.00014 & -0.00317 \\
5 & 1338 & 0.00063 & 1181 & 1324 & 0.00012 & 0.00219 \\
6 & 1370 & 0.00177 & 1223 & 1353 & 0.00024 & 0.01033 \\
7 & 1351 & 0.00323 & 1197 & 1336 & 0.00006 & 0.00835 \\
8 & 1329 & 0.00545 & 1180 & 1318 & 0.00015 & 0.00528 \\
9 & 1348 & 0.01014 & 1177 & 1331 & 0.00015 & 0.01316 \\
10 & 1300 & 0.06622 & 1140 & 1263 & 0.00002 & 0.03416 \\
\multicolumn{5}{l}{Hedge return (Portfolio 10 - Portfolio 1)} & 0.00043 & 0.04130\\
\midrule
\end{tabular*}
\end{subtable}
\bigskip
\begin{subtable}{\textwidth}
\begin{threeparttable}
\caption*{\textbf{Panel C:} Portfolio Ranks formed according to SUE3} 
\label{tab:PortfolioSUE3}
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l 
  S[table-format=4.0]
  S[table-format=-1.5]
  *{2}{S[table-format=4.0]}
  *{2}{S[table-format=-1.5]}
  @{}
}
1 & 1231 & -0.02934 & 1084 & 1213 & 0.00196 & -0.02531 \\
2 & 1232 & -0.00173 & 1052 & 1223 & 0.00043 & -0.01476 \\
3 & 1200 & -0.00032 & 1046 & 1196 & 0.00030 & -0.01422 \\
4 & 1252 & 0.00028 & 1110 & 1245 & 0.00030 & 0.00016 \\
5 & 1181 & 0.00058 & 1028 & 1177 & 0.00021 & 0.00516 \\
6 & 1220 & 0.00097 & 1060 & 1215 & 0.00007 & 0.00587 \\
7 & 1195 & 0.00152 & 1050 & 1186 & 0.00020 & 0.00998 \\
8 & 1193 & 0.00228 & 1046 & 1185 & -0.00037 & 0.02167 \\
9 & 1249 & 0.00386 & 1099 & 1246 & 0.00042 & 0.02336 \\
10 & 1171 & 0.01378 & 1065 & 1162 & -0.00089 & 0.04821 \\
\multicolumn{5}{l}{Hedge return (Portfolio 10 - Portfolio 1)} & -0.00285 & 0.07352\\
\bottomrule
\end{tabular*}

\begin{tablenotes}
\item[a] A subtable-specific footnote
\end{tablenotes}

\end{threeparttable}
\end{subtable}

\end{table}

The result is the same for both versions. Thank you very much.

  • Please develop a habit of posting compilable examples rather than just code snippets. A (minimal) compilable example starts with \documentclass, loads all packages and provides all macros needed to compile the program, and ends with \end{document}. – Mico Aug 10 '14 at 22:12
  • @Mico: I am sorry, always forgetting that. – eternity1 Aug 10 '14 at 22:44
2

Unless I'm missing something important, I don't see the point in creating three separate tabular* environments, each encased in a subtable environment, for the matter at hand. If you really need to assure consistent column widths across the three subparts, the easiest method by far is to create just one tabular* (or tabular, or whatever) environment. Losing the flexibility of being to cross-reference the three subparts individually should be worth it.

Incidentally, if a d{4.0} columns only every contain numbers consisting of exactly four digits, you can simplify life by specifying an ordinary c column type for the column(s) in question. Separately, since the three panels only just fit onto a single page, there's probably no point in embedding them in a threeparttable environment.

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage[left=4cm, right=3cm, top=3cm, bottom=4cm]{geometry} 
\usepackage{booktabs} % \toprule, \midrule, etc 
\usepackage[labelsep=newline,% line break after label
   justification=raggedright,
   singlelinecheck=off]{caption}
\usepackage{dcolumn} % decimal point alignment
\newcolumntype{d}[1]{D{.}{.}{#1}}

\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{table}[ht!]
\setlength\tabcolsep{0.1pt}  % default value: 6.0pt
\caption{Post-Announcement Returns to Earnings Surprise Portfolios}
\label{tab:PortfolioReturns}

\begin{tabular*}{\textwidth}%
  { @{\extracolsep{\fill}} l c d{2.5} cc *{2}{d{2.5}} }
\toprule
Surprise Portfolio  & N & \multicolumn{1}{c}{mean} & \multicolumn{2}{c}{N} & \multicolumn{2}{c}{mean} \\
\cmidrule{4-5} \cmidrule{6-7}
& & & CASC & BHAR & \mc{CASC} & \mc{BHAR} \\
\midrule
\multicolumn{7}{l}{Panel A: Portfolio Ranks formed according to SUE1} \\[0.5ex]
1 & 1389 & -0.09759 & 1226 & 1350 & -0.00029 & -0.00566 \\
2 & 1348 & -0.01259 & 1181 & 1331 & 0.00065 & -0.00232 \\
3 & 1390 & -0.00447 & 1213 & 1367 & 0.00050 & -0.00404 \\
4 & 1376 & -0.00184 & 1164 & 1360 & 0.00009 & -0.00140 \\
5 & 1402 & 0.00046 & 1222 & 1383 & 0.00025 & 0.00189 \\
6 & 1331 & 0.00180 & 1175 & 1322 & 0.00025 & 0.00667 \\
7 & 1349 & 0.00368 & 1182 & 1333 & 0.00019 & 0.00675 \\
8 & 1327 & 0.00622 & 1193 & 1318 & 0.00031 & 0.00557 \\
9 & 1303 & 0.01191 & 1137 & 1283 & 0.00002 & 0.01829 \\
10 & 1335 & 0.08969 & 1183 & 1300 & -0.00044 & 0.03208 \\[0.5ex]
\multicolumn{5}{l}{Hedge return (Portfolio 10 $-$ Portfolio 1)} & -0.00015 & 0.03774\\
\midrule
\multicolumn{7}{l}{Panel B: Portfolio Ranks formed according to SUE2} \\[0.5ex]
1 & 1409 & -0.06690 & 1235 & 1372 & -0.00041 & -0.00714 \\
2 & 1324 & -0.01011 & 1164 & 1306 & 0.00086 & -0.00222 \\
3 & 1382 & -0.00383 & 1182 & 1363 & 0.00049 & -0.00555 \\
4 & 1419 & -0.00136 & 1207 & 1399 & 0.00014 & -0.00317 \\
5 & 1338 & 0.00063 & 1181 & 1324 & 0.00012 & 0.00219 \\
6 & 1370 & 0.00177 & 1223 & 1353 & 0.00024 & 0.01033 \\
7 & 1351 & 0.00323 & 1197 & 1336 & 0.00006 & 0.00835 \\
8 & 1329 & 0.00545 & 1180 & 1318 & 0.00015 & 0.00528 \\
9 & 1348 & 0.01014 & 1177 & 1331 & 0.00015 & 0.01316 \\
10 & 1300 & 0.06622 & 1140 & 1263 & 0.00002 & 0.03416 \\[0.5ex]
\multicolumn{5}{l}{Hedge return (Portfolio 10 $-$ Portfolio 1)} & 0.00043 & 0.04130\\
\midrule
\multicolumn{7}{l}{Panel C: Portfolio Ranks formed according to SUE3} \\[0.5ex]
1 & 1231 & -0.02934 & 1084 & 1213 & 0.00196 & -0.02531 \\
2 & 1232 & -0.00173 & 1052 & 1223 & 0.00043 & -0.01476 \\
3 & 1200 & -0.00032 & 1046 & 1196 & 0.00030 & -0.01422 \\
4 & 1252 & 0.00028 & 1110 & 1245 & 0.00030 & 0.00016 \\
5 & 1181 & 0.00058 & 1028 & 1177 & 0.00021 & 0.00516 \\
6 & 1220 & 0.00097 & 1060 & 1215 & 0.00007 & 0.00587 \\
7 & 1195 & 0.00152 & 1050 & 1186 & 0.00020 & 0.00998 \\
8 & 1193 & 0.00228 & 1046 & 1185 & -0.00037 & 0.02167 \\
9 & 1249 & 0.00386 & 1099 & 1246 & 0.00042 & 0.02336 \\
10 & 1171 & 0.01378 & 1065 & 1162 & -0.00089 & 0.04821 \\[0.5ex]
\multicolumn{5}{l}{Hedge return (Portfolio 10 $-$ Portfolio 1)} & -0.00285 & 0.07352\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
  • Dear Mico, thank you very much for your help! I was considering this possibility too (but I did not know to use "c" instead of "d". In this case cross-referencing to the "subtables" isn´t that important. So I could do it manually (Panel A, B, C is not going to change names). Thank you for cleaning up the data. – eternity1 Aug 10 '14 at 22:49
  • Why did you change the S columns to d? – egreg Aug 10 '14 at 23:06
  • @egreg - I haven't changed from S to d -- I've stuck with the dcolumn-based method all along. Note that the OP posted two versions, presumably based on our earlier respective answers. – Mico Aug 10 '14 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.