Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Regarding to the following question Problem with subcaptions in subtables I created the following. There appears three problems: in the header starting from "Mean" to "Max." The alignment seems not to work properly. Also for integers there appears the problem because they are aligned by an "invisible decimal point". And lastly, the numbers in column 4 5nd 5 "overwrite" each other.

I tried to overwrite (as suggested in the question link) with \mc{} (\multicolumn{1}{c}{}) but could not make it work.

\begin{table}[ht!]
\setlength\tabcolsep{0.1pt}  % default value: 6.0pt

\begin{threeparttable}

\caption{Summary Statistics}
\label{tab:SummaryStatistics}

\begin{tabular*}{\textwidth}%
  { @{\extracolsep{\fill}} l *{3}{d{5.0}} *{3}{d{2.4}} 
      *{2}{d{5.0}} *{2}{d{2.4}} @{} }

\toprule
Variable 
& \multicolumn{1}{c}{N} & \multicolumn{1}{c}{Mean} & \multicolumn{1}{c}{Std. Dev.} & \multicolumn{1}{c}{Min.} & \multicolumn{1}{c}{Q1} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Q3} & \multicolumn{1}{c}{Max.} \\
\midrule
\multicolumn{9}{l}{Earnings Surprise}                                                                  \\
\noindent\hspace*{3mm} SUE1 & 14070 & -0.001 & 0.182 & -7.450 & -0.003 & 0.001 & 0.005 & 6.240 \\
\noindent\hspace*{3mm} SUE2 & 14081 & 0.000 & 0.154 & -7.440 & -0.002 & 0.001 & 0.005 & 6.250 \\
\noindent\hspace*{3mm} SUE3 & 12604 & -0.001 & 0.134 & -8.180 & 0.000 & 0.001 & 0.002 & 7.090 \\
\multicolumn{9}{l}{Firm Characteristic} \\
%\noindent\hspace*{5mm} CASC (in bps)                                                                      & 12309 & 2.492  & 0.016     & -6199 & -9.790 & 0.000  & 9.770 & 6078 \\
\noindent\hspace*{3mm} CASC & 12309 & 0.000 & 0.016 & -0.620 & -0.001 & 0.000 & 0.001 & 0.608 \\
\noindent\hspace*{3mm} BHAR & 13885 & 0.006 & 0.143 & -0.874 & -0.066 & 0.002 & 0.070 & 2.530 \\
\noindent\hspace*{3mm} DVOLA & 13866 & 0.000  & 0.004 & -0.043 & -0.001 & 0.000 & 0.001 & 0.104 \\
\noindent\hspace*{3mm} \begin{tabular}[c]{@{}l@{}}Market Value of\\ \noindent\hspace*{2mm}Equity (in mio)\end{tabular} & \multicolumn{1}{c}{14012}& \multicolumn{1}{c}{21467} & \multicolumn{1}{c}{40919} & \multicolumn{1}{c}{52} & \multicolumn{1}{c}{3329} & \multicolumn{1}{c}{8082} & \multicolumn{1}{c}{20408} & \multicolumn{1}{c}{510201} \\
\noindent\hspace*{3mm} LEVERAGE & 12756 & 0.299 & 0.203     & 0.000 & 0.144 & 0.252 & 0.420 & 1.000 \\
\noindent\hspace*{3mm} DLEVERAGE & 12107 & 0.001 & 0.042 & -0.274 & -0.017 & -0.002 & 0.015 & 0.461 \\
\noindent\hspace*{3mm} UPGRADE & 14094 & 0.022 & 0.148 &  0.000 & 0.000 & 0.000 & 0.000 & 1.000 \\
\noindent\hspace*{3mm} DOWNGRADE & 14094 & 0.036 & 0.186 & 0.000 & 0.000 & 0.000 & 0.000 & 1.000 \\
\multicolumn{9}{l}{Macroeconomic Factors} \\
\noindent\hspace*{3mm} SPOT & 14058 & 0.029 & 0.014 & 0.006 & 0.019 & 0.030 & 0.041 & 0.052 \\
\noindent\hspace*{3mm} DSPOT & 13489 & -0.001 & 0.004     & -0.016 & -0.003 & 0.000 & 0.002 & 0.013 \\
\noindent\hspace*{3mm} SLOPE & 14058 & 0.014 & 0.010 & -0.002 & 0.003 & 0.016 & 0.023 & 0.029 \\
\noindent\hspace*{3mm} DSLOPE & 13489 & 0.000 & 0.003     & -0.011 & -0.003 & -0.001 & 0.002 & 0.012 \\ [1ex]
\bottomrule
\end{tabular*}
\begin{tablenotes}
\footnotesize
\item This is where authors provide additional information about the data, including whatever notes are needed.
\end{tablenotes}
\end{threeparttable}
\end{table}

Additionally, I get an error "Badbox" (Overfull \hbox ...). Is that because the table is actually "too big" for the page?

BTW, the row "Market Value of equity" was an attempt to wrap the text within the column. I am not sure if this is a "smart" way to handle such things :)

share|improve this question

2 Answers 2

up vote 5 down vote accepted

I'd again use siunitx. I'd also add a rule to separate the various sectors of the table and set the subtitles in a different font, to make it clearer they're a different type of entry.

I'm not sure about the row with different data types.

\documentclass[draft]{article}
\usepackage[margin=1in]{geometry}  % choose margins here

\usepackage{booktabs} % for \toprule, \midrule, \bottomrule, and \cmidrule
\usepackage[labelsep=newline,% line break after label
   justification=raggedright,
   singlelinecheck=off]{caption}

\usepackage{threeparttable}
\usepackage{siunitx}

\begin{document}

\begin{table}[!htp]
\sisetup{group-separator={}}
\begin{threeparttable}

\caption{Summary Statistics}
\label{tab:SummaryStatistics}

\begin{tabular*}{\textwidth}
  {
   @{\extracolsep{\fill}}
   l
   S[table-format=5.0]
   S[table-format=-1.3]
   S[table-format=1.3]
   S[table-format=-1.3]
   S[table-format=-1.3]
   S[table-format=-1.3]
   S[table-format=1.3]
   S[table-format=1.3]
   @{}
  }
\toprule
Variable 
  & {N} & {Mean} & {Std.\ Dev.} & {Min.} & {Q1} & {Median} & {Q3} & {Max.} \\
\midrule
\multicolumn{9}{@{}l}{\itshape Earnings Surprise} \\
SUE1
  & 14070 & -0.001 & 0.182 & -7.450 & -0.003 & 0.001 & 0.005 & 6.240 \\
SUE2
  & 14081 & 0.000 & 0.154 & -7.440 & -0.002 & 0.001 & 0.005 & 6.250 \\
SUE3
  & 12604 & -0.001 & 0.134 & -8.180 & 0.000 & 0.001 & 0.002 & 7.090 \\
\midrule
\multicolumn{9}{@{}l}{\itshape Firm Characteristic} \\
%CASC (in bps)
%  & 12309 & 2.492  & 0.016     & -6199 & -9.790 & 0.000  & 9.770 & 6078 \\
CASC
  & 12309 & 0.000 & 0.016 & -0.620 & -0.001 & 0.000 & 0.001 & 0.608 \\
BHAR
  & 13885 & 0.006 & 0.143 & -0.874 & -0.066 & 0.002 & 0.070 & 2.530 \\
DVOLA
  & 13866 & 0.000  & 0.004 & -0.043 & -0.001 & 0.000 & 0.001 & 0.104 \\
\begin{tabular}[c]{@{}l@{}}
  Market Value of\\
  Equity (in mio)
\end{tabular}
   & {14012} & {\hphantom{$-$}21467} & {40919} & {\hphantom{$-$}52} & {\hphantom{$-$}3329} & {\hphantom{$-$}8082} & {20408} & {510201} \\
LEVERAGE
  & 12756 & 0.299 & 0.203     & 0.000 & 0.144 & 0.252 & 0.420 & 1.000 \\
DLEVERAGE
  & 12107 & 0.001 & 0.042 & -0.274 & -0.017 & -0.002 & 0.015 & 0.461 \\
UPGRADE
  & 14094 & 0.022 & 0.148 &  0.000 & 0.000 & 0.000 & 0.000 & 1.000 \\
DOWNGRADE
  & 14094 & 0.036 & 0.186 & 0.000 & 0.000 & 0.000 & 0.000 & 1.000 \\
\midrule
\multicolumn{9}{@{}l}{\itshape Macroeconomic Factors} \\
SPOT
  & 14058 & 0.029 & 0.014 & 0.006 & 0.019 & 0.030 & 0.041 & 0.052 \\
DSPOT
  & 13489 & -0.001 & 0.004     & -0.016 & -0.003 & 0.000 & 0.002 & 0.013 \\
SLOPE
  & 14058 & 0.014 & 0.010 & -0.002 & 0.003 & 0.016 & 0.023 & 0.029 \\
DSLOPE
  & 13489 & 0.000 & 0.003     & -0.011 & -0.003 & -0.001 & 0.002 & 0.012 \\ [1ex]
\bottomrule
\end{tabular*}
\begin{tablenotes}
\footnotesize
\item This is where authors provide additional information about the data,
      including whatever notes are needed.
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}

enter image description here

share|improve this answer
    
dear egreg: thank you for the modification. WHen I specifiy my margins in the -geometry- package, the table does "not fit" anymore. The last two columns are just "printed" to the border. THe following margins are set: a4paper, left=4cm, right=3cm, top=3cm, bottom=4cm. Do I have to change the specification "table-format"? –  eternity1 Aug 10 at 19:34
    
@eternity1 If you have narrower text width, you can use \small at the beginning of the table environment, in order to reduce the type size. –  egreg Aug 10 at 19:37
    
I specify my fontsize in the \documentclass command as 12pt. Is there a possibility to keep 12pt where it actually is possible and reduce the size when necessary, for example the tables? like to tell the programm to automatically reduce the size in order to fit the paper? –  eternity1 Aug 10 at 20:12
    
@eternity1 Doing \small is exactly the way. –  egreg Aug 10 at 20:15
    
\small is still too big, but \footnotesize worked fine. –  eternity1 Aug 10 at 20:22

Here's a solution that uses the dcolumn package to align (most) numbers on their decimal points. Note that this table has 8 data columns: The first contains 5-digit integers without a decimal, hence d{5.0} is good. The remaining seven columns can all be given the specification d{2.3}: two digits (including the sign) before the decimal marker, and three digits after the decimal marker.

There's only one data row that doesn't fit this pattern, the row of market values, whose numbers are expressed in millions of some currency unit (dollars? euros? yen? pounds?). For such numbers, it's convenient to center-set them; this can be done easily by encasing them in \multicolumn{1}{c}{21467}, \multicolumn{1}{c}{40919}, etc statements. (Given the definition of the \mc shortcut macro, these statements can be written more succinctly as \mc{21437}, \mc{40919}, etc.) Note that this encasing in \multicolumn{1}{c}{...} wrappers for numbers works in exactly the same way as it does for cells of the header row which contain text rather than numbers ("Mean", "St. Dev", etc).

enter image description here

\documentclass{article}
\usepackage[margin=1in]{geometry}  % choose margins here
\usepackage{threeparttable}
\usepackage{booktabs} % \toprule, \midrule, \bottomrule, 
\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

\begin{threeparttable}
\caption{Summary Statistics}
\label{tab:SummaryStatistics}

\begin{tabular*}{\textwidth}%
  { @{\extracolsep{\fill}} l d{5.0} *{7}{d{2.3}} }
\toprule
Variable\tnote{a} 
& \mc{N} & \mc{Mean} & \mc{St.\,Dev.} & \mc{Min.} & \mc{Q1} & \mc{Median} & \mc{Q3} & \mc{Max.} \\
\midrule
\multicolumn{9}{l}{Earnings Surprise} \\
\noindent\hspace*{3mm} SUE1 & 14070 & -0.001 & 0.182 & -7.450 & -0.003 & 0.001 & 0.005 & 6.240 \\
\noindent\hspace*{3mm} SUE2 & 14081 & 0.000 & 0.154 & -7.440 & -0.002 & 0.001 & 0.005 & 6.250 \\
\noindent\hspace*{3mm} SUE3 & 12604 & -0.001 & 0.134 & -8.180 & 0.000 & 0.001 & 0.002 & 7.090 \\
\multicolumn{9}{l}{Firm Characteristics} \\
%\noindent\hspace*{5mm} CASC (in bps) & 12309 & 2.492  & 0.016 & -6199 & -9.790 & 0.000  & 9.770 & 6078 \\
\noindent\hspace*{3mm} CASC & 12309 & 0.000 & 0.016 & -0.620 & -0.001 & 0.000 & 0.001 & 0.608 \\
\noindent\hspace*{3mm} BHAR & 13885 & 0.006 & 0.143 & -0.874 & -0.066 & 0.002 & 0.070 & 2.530 \\
\noindent\hspace*{3mm} DVOLA & 13866 & 0.000  & 0.004 & -0.043 & -0.001 & 0.000 & 0.001 & 0.104 \\
\noindent\hspace*{3mm} 
\begin{tabular}[c]{@{}l@{}}
Market Value of\\ \noindent\hspace*{3mm}Equity (in mio)
\end{tabular} 
& 14012 & \mc{21467} & \mc{40919} & \mc{52} & \mc{3329} & \mc{8082} & \mc{20408} & \mc{510201} \\
\noindent\hspace*{3mm} LEVERAGE & 12756 & 0.299 & 0.203     & 0.000 & 0.144 & 0.252 & 0.420 & 1.000 \\
\noindent\hspace*{3mm} DLEVERAGE & 12107 & 0.001 & 0.042 & -0.274 & -0.017 & -0.002 & 0.015 & 0.461 \\
\noindent\hspace*{3mm} UPGRADE & 14094 & 0.022 & 0.148 &  0.000 & 0.000 & 0.000 & 0.000 & 1.000 \\
\noindent\hspace*{3mm} DOWNGRADE & 14094 & 0.036 & 0.186 & 0.000 & 0.000 & 0.000 & 0.000 & 1.000 \\
\multicolumn{9}{l}{Macroeconomic Factors} \\
\noindent\hspace*{3mm} SPOT & 14058 & 0.029 & 0.014 & 0.006 & 0.019 & 0.030 & 0.041 & 0.052 \\
\noindent\hspace*{3mm} DSPOT & 13489 & -0.001 & 0.004 & -0.016 & -0.003 & 0.000 & 0.002 & 0.013 \\
\noindent\hspace*{3mm} SLOPE & 14058 & 0.014 & 0.010 & -0.002 & 0.003 & 0.016 & 0.023 & 0.029 \\
\noindent\hspace*{3mm} DSLOPE & 13489 & 0.000 & 0.003 & -0.011 & -0.003 & -0.001 & 0.002 & 0.012 \\
\bottomrule
\end{tabular*}
\begin{tablenotes}
\footnotesize
\item[a] A table-specific footnote
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
share|improve this answer
    
Dear Mico, thank you for the dolumn version. Like for egreg´s solution the problems appears here as well. Is it due to my margin specification? –  eternity1 Aug 10 at 20:10
    
@eternity1 - I see from some of the other comments that you use 12pt instead of 10pt as the main document font size. However, that change alone should not make table above too big to fit in the assumed text block, as long as the paper size is either a4 or (US) letter and the left-hand and right-hand margins are 1". What are the actual dimensions of your document? Please advise. –  Mico Aug 10 at 20:17
    
Exactly, with margins set to 1 inch it is fine; my margins are defined as a4paper, left=4cm, right=3cm, top=3cm, bottom=4cm. I tried to put /small in the environment and it does work, but as let latex "calculate automatically", I wonder if that could be possible too. –  eternity1 Aug 10 at 20:29
    
@eternity1 - Good to know that you can get by with choosing \small, i.e., implementing a (linear) font size reduction of only ca 10%. Font sizes are, as you must know too, an absolutely crucial part of document. I would definitely not delegate to LaTeX a choice over \small or \footnotesize. –  Mico Aug 10 at 20:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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