2
\documentclass[12pt]{article}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage[a4paper]{geometry}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{textcomp}
\usepackage{subfigure}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage[margin=10pt,font=small,labelfont=bf, labelsep=endash]{caption}
\usepackage{booktabs}
\begin{document}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\begin{table*}[h]
\centering
\ra{1}
\resizebox{\textwidth}{!}{
\begin{tabular}{cccccccccc}\toprule
&& \multicolumn{2}{c}{Phase 1} & \phantom{ab}& \multicolumn{2}{c}{Phase 2} && \multicolumn{2}{c}{Phase 3}\\
\cmidrule{3-4}              \cmidrule{6-7}          \cmidrule{9-10}
Day &\phantom{ab}& AAR & CAAR & \phantom{ab} & AAR & CAAR & \phantom{ab} & AAR & CAAR \\ \midrule
$-10$ & \phantom{ab}&0.00211&0.00211 &\phantom{ab}& -0.00104& 0.6& \phantom{ab}&0.00211&0.7\\
 &\phantom{ab}& \footnotesize(0.61)& \footnotesize(0.61)&\phantom{ab}& \footnotesize(0.61)\\
$-9$ & \phantom{ab}& 0.00242 &0.00453 & \phantom{ab}&0.00211 & 0.6& \phantom{ab}&0.00211&0.7\\
&\phantom{ab}& \footnotesize(0.90)& \footnotesize (1.04)&\phantom{ab}& \footnotesize(0.61)\\
\hline\hline
\multicolumn{3}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\multicolumn{3}{l}{\footnotesize {*} \(p<0.05\), {**} \(p<0.01\), {***} \(p<0.001\)}\\
\bottomrule
\end{tabular}
}
\end{table*}\end{document}

Hi,guys. I am trying to create a nice-looking table and I have encountered some issues. First, is there any way to get rid of \footnotesize in every second row and make automatic fontsize change? And second, how to make the line under "Phase 1" be a bit shorter from the left side so that it was right above the numbers? Table 1.

  • Welcome to TeX.sx! Thanks for posting a complete code here. But you could minimize it a lot more, which would make it easier for us. Some other points: Do not load booktabs and amsmath twice. The latter is not needed here and could be replaced by the newer mathtools. Do not use \hlines inside such a nice booktabs-table. You should put numbers in between $$. The minus is displayed incorrectly. You can shorten the left side of a \cmidrule as \cmidrule(l){3-4}. The rest of the superseding line comes from wrong spacing (maybe all those strange phantoms). – LaRiFaRi Aug 17 '16 at 08:21

2 Answers2

3

Avoid scaling tables, but if you do don't leave a space to the left and right you would need \resizebox{\textwidth}{!}{%

Here I just define the t-statistics to be part of the same cell

enter image description here

No idea why the extra columns of phantoms were there, so I removed them.

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage[a4paper]{geometry}

\usepackage{booktabs}
\usepackage{array}
\usepackage{amsmath}
\usepackage[margin=10pt,font=small,labelfont=bf, labelsep=endash]{caption}
\def\tstat#1(#2){\begin{array}[t]{@{}c@{}}#1\\[-3pt]\scriptstyle(#2)\end{array}}
\begin{document}

\begin{table}
\centering

\begin{tabular}{r*{3}{>{\tstat}c}ccc}\toprule
& \multicolumn{2}{c}{Phase 1} &
\multicolumn{2}{c}{Phase 2}& 
\multicolumn{2}{c}{Phase 3}\\
\cmidrule(r{.7em}l{.7em}){2-3}
\cmidrule(r{.7em}l{.7em}){4-5}
\cmidrule(r{.7em}l{.7em}){6-7}
\multicolumn{1}{c}{Day}&
\multicolumn{1}{c}{AAR} &
\multicolumn{1}{c}{CAAR} &
\multicolumn{1}{c}{AAR} &
CAAR  & AAR & CAAR \\ \midrule
$-10$ & 0.00211 (0.61)&0.00211 (0.61)& -0.00104(0.61)& 0.6& 0.00211&0.7\\
$-9$ &  0.00242 (0.90)&0.00453 (1.04)& 0.00211 (0.61)& 0.6& 0.00211&0.7\\
\hline\hline
\multicolumn{3}{l}{\footnotesize $t$ statistics in parentheses}\\
\multicolumn{3}{l}{\footnotesize {*} \(p<0.05\), {**} \(p<0.01\), {***} \(p<0.001\)}\\
\bottomrule
\end{tabular}

\end{table}

\end{document}
David Carlisle
  • 757,742
2

Here is a start, it is not yet automated, but shows you some improvements. I do not have time to finish right now. Please help your self with the code, you like.

% arara: pdflatex

\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{caption}
\usepackage{array}
\makeatletter
\g@addto@macro{\endtabular}{\rowfont{}}% 
\makeatother
\newcommand{\rowfonttype}{}% 
\newcommand{\rowfont}[1]{% 
    \gdef\rowfonttype{#1}#1% credits to http://tex.stackexchange.com/a/62858
}
\newcolumntype{L}{>{\rowfonttype}l}
\newcolumntype{C}{>{\rowfonttype}c}

\begin{document}
\begin{table}
    \centering
    \begin{threeparttable}
        \caption{some table ($t$ statistics in parentheses)}
        \begin{tabular}{L@{\hspace{1cm}}*{6}{C}}
            \toprule
            & \multicolumn{2}{c}{Phase 1} &  \multicolumn{2}{c}{Phase 2} & \multicolumn{2}{c}{Phase 3} \\
            \cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
            Day & AAR & CAAR &  AAR & CAAR & AAR & CAAR \\ 
            \midrule
            $-10$ & 0.00211 & 0.00211 & $-0.00104$ & 0.6 & 0.00211 & 0.7 \\
            \rowfont{\footnotesize}%
            & (0.61) & (0.61) & (0.61) & & & \\
            \rowfont{\normalsize}%
            $-9$ & 0.00242 & 0.00453 & 0.00211 & 0.6 & 0.00211 & 0.7 \\
            \rowfont{\footnotesize}%
            & (0.90) & (1.04)& (0.61) & & & \\
            \bottomrule
        \end{tabular}
        \begin{tablenotes}[para]
            \item[*] $p<0.05$
            \item[**] $p<0.01$
            \item[***] $p<0.001$
        \end{tablenotes}
    \end{threeparttable}
\end{table}
\end{document}

enter image description here

After all, I would not recommend to do so. It looks disturbing if the font changes so often. Please also note the different vertical spacing which is ugly and pushes the small numbers in the wrong direction. I would leave all numbers in same size and take a look on the tables from the siunitx package. You will get all numbers and dots aligned which is much easier to read. Use some \addlinespace after each other row and the table will be perfect.

LaRiFaRi
  • 43,807
  • @AnnaIgnashkina Glad to hear that. You are welcome! – LaRiFaRi Aug 17 '16 at 08:58
  • You can imho automate it with \usepackage[table]{xcolor} and \rowcolors* [\noalign{\ifodd\rownum \rowfont{\footnotesize}\else\rowfont{\normalsize}\fi}]{3}{}{} before the tabular. – Ulrike Fischer Aug 17 '16 at 11:28