2

I am trying to create an appendix of tables, but my first table jumps to the second page. I have gone through most of entries on Keeping tables/figures close to where they are mentioned but none of them seem to work.

\documentclass[12pt]{article}
\addtolength{\parskip}{\baselineskip}
\usepackage[margin=1in,includefoot]{geometry}
\usepackage[fleqn]{amsmath}
\usepackage{mathtools}
\usepackage{siunitx}
\setlength{\parindent}{0.25in} 


%Tables preamble
\usepackage[none]{hyphenat}
\usepackage{float}
\usepackage[thinlines]{easytable}
\usepackage{longtable}
\usepackage{array,booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mceight[1]{\multicolumn{8}{l}{#1}}
\newcommand\mctwelve[1]{\multicolumn{12}{c}{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{tabularx}

\widowpenalty500
\clubpenalty500
\exhyphenpenalty=50 %for line-breaking at an explicit hyphen
\brokenpenalty=4991
\predisplaypenalty=10000
\postdisplaypenalty=1549
\displaywidowpenalty=1602
\floatingpenalty = 20000

\usepackage[labelfont=bf, textfont=bf]{caption}

\section{Appendix}
\subsection{Appendix of Tables}

\newgeometry{margin=0.4in} 

\begin{table}[!htbp]
\caption{Summary statistics 1}
\fontsize{10}{12}\selectfont
\sisetup{detect-all}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
    l S[table-format=2.2]     S[table-format=2.0]
    *{3}{S[table-format=2.2]} S[table-format=3.0]} 
\toprule
 & & & \multicolumn{3}{c}{Quantiles} \\
    \cmidrule(lr){4-6}
\textbf{Variable} & \textbf{Mean} & \textbf{Minimum} & \textbf{25th percentile} & \textbf{Median} & \textbf{75th percentile} & \textbf{Maximum} \\ \midrule
\textbf{Panel A: Female labour force} \\ \midrule
\textbf{2004-05} \\ \hdashline
{Hourly wage}  & 12.52 & 0 & 3.75 & 5.48 & 12.5 & 250\ \\ \hdashline
{Age (in years)}&  31.56 & 15 & 22 & 29 & 38 & 60\ \\ \hdashline
{Years of experience} & 7.9 & 0 & 8 & 15 & 25 & 40\ \\ \hdashline
{Years of education} & 17.63 & 0 & 0 & 8 & 12 & 16\ \\ \hdashline
\\
\textbf{2011-12} \\ \hdashline
{Hourly wage} & 29.44 & 1 & 10 & 15 & 30 & 328\ \\ \hdashline
{Age (in years)} & 35.06 & 15 & 28 & 35 & 42 & 60\ \\ \hdashline
{Years of education} & 7.13 & 0 & 0 & 8 & 12 & 16\ \\ \hdashline
{Years of experience} & 21.93 & 0 & 13 & 23 & 31 & 40\ \\ \hdashline
\bottomrule
\end{tabular*}
\end{table}
\end{document}

1 Answer 1

2

cause of your problem is use of newgeometry. it always start new page ...

removing it and slightly redesign table (make shorter columns heads) i obtain:

enter image description here

\documentclass[12pt]{article}
\usepackage[margin=1in,includefoot]{geometry}
\usepackage[fleqn]{mathtools}
\usepackage{siunitx}
\setlength{\parindent}{0.25in}
\addtolength{\parskip}{\baselineskip}


%Tables preamble
\usepackage[none]{hyphenat}
%\usepackage{float}
%\usepackage[thinlines]{easytable}
\usepackage{array,booktabs, longtable, makecell, multirow,tabularx}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mceight[1]{\multicolumn{8}{l}{#1}}
\newcommand\mctwelve[1]{\multicolumn{12}{c}{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
%\usepackage{pdflscape}
%\usepackage{afterpage}
\usepackage[labelfont=bf, textfont=bf]{caption}

\begin{document}
\section{Appendix}
\subsection{Appendix of Tables}

%\newgeometry{margin=0.4in}

\begin{table}[htp]
\caption{Summary statistics 1}
\fontsize{10}{12}\selectfont
\sisetup{detect-all}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
    l S[table-format=2.2]     S[table-format=2.0]
    *{3}{S[table-format=2.2]} S[table-format=3.0]}
\toprule
 & & & \multicolumn{3}{c}{Quantiles} \\
    \cmidrule(lr){4-6}
\textbf{Variable} & \textbf{Mean} & \textbf{Min} & \textbf{25th percentile} & \textbf{Median} & \textbf{75th percentile} & \textbf{Max} \\ \midrule
\textbf{Panel A: Female labour force} \\ \midrule
\textbf{2004-05} \\ \hdashline
{Hourly wage}  & 12.52 & 0 & 3.75 & 5.48 & 12.5 & 250\ \\ \hdashline
{Age (in years)}&  31.56 & 15 & 22 & 29 & 38 & 60\ \\ \hdashline
{Years of experience} & 7.9 & 0 & 8 & 15 & 25 & 40\ \\ \hdashline
{Years of education} & 17.63 & 0 & 0 & 8 & 12 & 16\ \\ \hdashline
\\
\textbf{2011-12} \\ \hdashline
{Hourly wage} & 29.44 & 1 & 10 & 15 & 30 & 328\ \\ \hdashline
{Age (in years)} & 35.06 & 15 & 28 & 35 & 42 & 60\ \\ \hdashline
{Years of education} & 7.13 & 0 & 0 & 8 & 12 & 16\ \\ \hdashline
{Years of experience} & 21.93 & 0 & 13 & 23 & 31 & 40\ \\ \hdashline
\bottomrule
\end{tabular*}
\end{table}
\end{document}

off-topic: i would redesign table and correct wrongly writed some rows as follows:

\documentclass[12pt]{article}
\usepackage[margin=1in,includefoot]{geometry}
\usepackage[fleqn]{mathtools}
\usepackage{siunitx}
\setlength{\parindent}{0.25in}
\addtolength{\parskip}{\baselineskip}


%Tables preamble
\usepackage[none]{hyphenat}
%\usepackage{float}
%\usepackage[thinlines]{easytable}
\usepackage{array, booktabs, longtable, 
            makecell, multirow, tabularx, 
            threeparttable}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mceight[1]{\multicolumn{8}{l}{#1}}
\newcommand\mctwelve[1]{\multicolumn{12}{c}{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
%\usepackage{pdflscape}
%\usepackage{afterpage}
\usepackage[labelfont=bf, textfont=bf]{caption}

\begin{document}
\section{Appendix}
\subsection{Appendix of Tables}

\begin{threeparttable}[ht]
\caption{Summary statistics 1}
\fontsize{10}{12}\selectfont
\sisetup{detect-all}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
    l S[table-format=2.2]     S[table-format=2.0]
    *{3}{S[table-format=2.2]} S[table-format=3.0]}
\toprule
 & & & \multicolumn{3}{c}{Quantiles} \\
    \cmidrule{4-6}
\textbf{Variable} & \textbf{Mean}               & \textbf{Min} 
                  & \textbf{25th per. \tnote{a}}& \textbf{Median} 
                  & \textbf{75th per. \tnote{a}}& \textbf{Max}      \\ \midrule
\multicolumn{7}{l}{\textbf{Panel A: Female labour force}}           \\ \midrule
\multicolumn{7}{l}{\textbf{2004-05}}                                \\ 
    \hdashline
Hourly wage         & 12.52 &  0    &  3.75 &  5.48 & 12.5  & 250   \\
Age (in years)      & 31.56 & 15    & 22    & 29    & 38    & 60    \\
Years of experience &  7.9  &  0    &  8    & 15    & 25    & 40    \\
Years of education  & 17.63 &  0    &  0    &  8    & 12    & 16    \\ 
    \midrule
\multicolumn{7}{l}{\textbf{2011-12}}                                \\ 
    \hdashline
Hourly wage         & 29.44 &  1    & 10    & 15    & 30    & 328   \\
Age (in years)      & 35.06 & 15    & 28    & 35    & 42    & 60    \\
Years of education  &  7.13 &  0    &  0    &  8    & 12    & 16    \\
Years of experience & 21.93 &  0    & 13    & 23    & 31    & 40    \\
    \bottomrule
\end{tabular*}
\end{threeparttable}
\begin{tablenotes}[para, flushleft]\scriptsize
\item[a]    per.: percentile
\end{tablenotes}
\end{document}

enter image description here

You must log in to answer this question.

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