# Improvement for rebuilded table design

I want to rebuild the following table :

and came up with the following code :

\begin{table}
\centering
\begin{threeparttable}
\caption{ \\ \textit{Quantile Effects When Education is Treated as Exogenous} \\
\scriptsize (Sample size : 7,165) By gender (3,735 males and 3,430 females)}
\begin{tabular}{llllll}
\toprule
& $$\tau=0.10$$ & $$\tau= 0.30$$ & $$\tau= 0.50$$ & $$\tau= 0.70$$ & $$\tau= 0.90$$ \\
\midrule     \\
\textit{Males}    & $\underset{( 0.2359)}{-0.0852}$        & $\underset{(0.1127)}{0.0657}$    & $\underset{(0.1045)}{-0.1358}$       & $\underset{(0.1231)}{-0.0983}$ & $\underset{(0.1989)}{-0.2911}$    \\
\textit{Females}& $\underset{( 0.2090}{0.3149}$        & $\underset{(0.1034)}{0.0815}$    & $\underset{(0.097)}{-0.1358}$       & $\underset{(0.1035)}{0.1224}$ & $\underset{(0.2221)}{ 0.0947}$ \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item \textit{Note.} Each regression included a constant, country dummies,  \textit{q}, \textit{$q^2$} and their interactions with country dummies, age, age squared, and the GDP per head at the age when the pupil would have finished compulsory schooling. $\tau$  denotes the quantile of the distribution of wages. Three start, two stas and one star for statistically significant coefficients at the 1\%, 5\% and 10\% confidence level. Bootstrapped standard errors are shown in parentheses.
\end{tablenotes}
\end{threeparttable}
\end{table}


Which looks like this :

Specific improvement questions :

How can I center 'Table 5' and my caption in my result?

Is there any way to set the font-size of a threeparttable?

## 2 Answers

Here is a solution for the caption, with the homonymous package. I also improved a bit the table note. For the font size, this depends on which part you want to change it.

\documentclass{article}
\usepackage{amsmath}
\usepackage{threeparttable}
\usepackage{booktabs, array, caption}

\begin{document}

\begin{table}
\centering\captionsetup{labelsep=newline, justification=centering}
\begin{threeparttable}
\caption{\textit{Quantile Effects When Education is Treated as Exogenous} \\
\scriptsize (Sample size : 7,165) By gender (3,735 males and 3,430 females)}
\begin{tabular}{*{6}{l}}
\toprule
& $$\tau=0.10$$ & $$\tau= 0.30$$ & $$\tau= 0.50$$ & $$\tau= 0.70$$ & $$\tau= 0.90$$ \\
\midrule
\addlinespace
\textit{Males} & $\underset{( 0.2359)}{-0.0852}$ & $\underset{(0.1127)}{0.0657}$ & $\underset{(0.1045)}{-0.1358}$ & $\underset{(0.1231)}{-0.0983}$ & $\underset{(0.1989)}{-0.2911}$ \\
\textit{Females}& $\phantom{-}\underset{( 0.2090)}{0.3149}$ & $\underset{(0.1034)}{0.0815}$ & $\underset{(0.097)}{-0.1358}$ & $\phantom{-}\underset{(0.1035)}{0.1224}$ & $\phantom{-}\underset{(0.2221)}{ 0.0947}$ \\
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\small
\item \textit{Note.} Each regression included a constant, country dummies, \textit{q}, \textit{$q^2$} and their interactions with country dummies, age, age squared, and the GDP per head at the age when the pupil would have finished compulsory schooling. $\tau$ denotes the quantile of the distribution of wages. Three start, two stas and one star for statistically significant coefficients at the 1\%, 5\% and 10\% confidence level. Bootstrapped standard errors are shown in parentheses.
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}


• Hmm strange to say but my LaTex-Compiler (Knitr in R Markdown) throws me the following error : ! Package caption Error: \caption outside float. See the caption package documentation for explanation. Type H <return> for immediate help. ... l.642 \caption { \\ \textit{Quantile Effects When Education is Treated as Exo..  – mugdi Sep 29 at 19:52
• The error message shows it is not the exact code I used: I deleted the initial \\ in the caption text since I set labelsep=newline. In the posted code, \caption is inside the threeparttable environment. Please check the code you use. – Bernard Sep 29 at 20:01
• It is the exact code you used. See : [3]: i.stack.imgur.com/gXeGp.png But I think knitR is doing something terrible there wenn compiling the code D: – mugdi Sep 29 at 20:10
• Of course, I compiled with a basic pdflatex, and I don't know what knitR does, but I'm surprised, as it uses only standard packages. – Bernard Sep 29 at 20:15
• Yeah it is really strange, of course the code works for me perfectly fine when I use basic pdflatex or XeLatex, too. But I think I can find a workaround, say just compile the R-Code first and leave me with the plain Latex Code. The latter can be pushed into any standard Tex-Compiler and I will remove the erroneous backlashes. – mugdi Sep 29 at 20:19

Here's another possible solution. Observe that it aligns the decimal markers within each column. Since you seem to be keen on using a threepartable environment, I also suggest using \tnote directives. I don't think that the sample size information deserves to be all that close to the caption.

\documentclass{article}
\usepackage{booktabs}

\usepackage{siunitx}
\sisetup{input-symbols= (),
group-digits=false,
table-space-text-post = )}

\usepackage[flushleft]{threeparttable}
\renewcommand\TPTtagStyle{\textit}

\usepackage{caption}
\captionsetup{labelsep=newline,
textfont=it,
skip=0.333\baselineskip}

\begin{document}
\begin{table}
\centering
\begin{threeparttable}
\caption{Quantile effects when education is treated as exogenous\tnote{a,b}}

\begin{tabular}{@{} l *{5}{S[table-format=-1.4]} @{}}
\toprule
& \multicolumn{5}{c@{}}{$\tau$}\\
\cmidrule(l){2-6}
& 0.10 & 0.30 & 0.50 & 0.70 & 0.90 \\
\midrule
Males    & -0.0852 & 0.0657 & -0.1358 & -0.0983 & -0.2911 \\
& (0.2359) & (0.1127) & (0.1045) & (0.1231) & (0.1989) \\
\addlinespace
Females  &  0.3149 & 0.0815 & -0.1358 & 0.1224 & 0.0947 \\
& (0.2090) & (0.1034) & (0.097)  & (0.1035) & (0.2221) \\
\bottomrule
\end{tabular}

\smallskip\small
\begin{tablenotes}
\item[a]Sample size: 7,165. By gender: 3,735 males and 3,430 females.
\item[b]Each regression included a constant, country dummies,  \textit{q}, \textit{$q^2$} and their interactions with country dummies, age, age squared, and the GDP per head at the age when the pupil would have finished compulsory schooling. $\tau$  denotes the quantile of the distribution of wages. Three stars, two stars and one star denote statistically significant coefficients at the 1\%, 5\% and 10\% confidence levels. Bootstrapped standard errors are shown in parentheses.
\end{tablenotes}
\end{threeparttable}
\end{table}

\end {document}