[Tex/LaTex] Fitting tables to page length in landscape

landscapetables

enter image description here
I am trying to make the following two tables fit the page width, but I do not wish to use the sidewaystable environment. I need both the tables to be in landscape. Is there an alternative?

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

%Tables preamble
\usepackage[none]{hyphenat}
\usepackage{array}
\usepackage[thinlines]{easytable}
\usepackage{longtable}
\usepackage{array, 
booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage{pdflscape}
\usepackage{afterpage}


\begin{document}
 \afterpage{\clearpage}
 \thispagestyle{empty} 
 \begin{landscape}
\begin{table}[ht] \centering
\caption{Oaxaca Blinder Decomposition results}
\begin{tabular}{ l*{6}{S[table-format=2.2]} } \toprule
\label{tab:oaxaca}
\thead[b]{Terms of \\ decomposition}  & \multicolumn{3}{c}{2011-12} & \multicolumn{3}{c}{2004-05} \\
   \cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){5-7}
   \midrule
& \textbf{women ws} & \textbf{male ws} & \textbf{pooled ws} & \textbf{women ws} & \textbf{male ws} & \textbf{pooled ws} \\ \hline
 \\
{Difference} & 0.39 & 0.39 & 0.39 & 0.48 & 0.48 & 0.48 \\ \hdashline
{Explained} & -0.02 & 0.00 & -0.01 & 0.07 & 0.10 & 0.09 \\ \hdashline
{Unexplained} & 0.48 & 0.39 & 0.40 & 0.41 & 0.37 & 0.38 \\ \hline
\textbf{Percent unexplained} & 102.95 & 98.42 & 99.62 & 85.42 & 78.88 & 79.49 \\
 \bottomrule
  \end{tabular}
\end{table}

\begin{table}[ht] \centering
\caption{MMM Decomposition results}
\begin{tabular}{ l*{9}{S[table-format=2.2]} }\toprule
\textbf{Deciles} & \textbf{Men} & \textbf{Women} & \textbf{Difference} & \multicolumn{3}{c}{Returns to women} & \multicolumn{3}{c}{Returns to men} \\
 \cmidrule(lr){5-7}\cmidrule(lr){8-10}
 \midrule
 &  &  &  & {CF1} & {Charac} & {Coeff} & {CF2} & {Charac} & {Coeff} \\ \midrule
{Panel A: 2011-12} \\ \hline
{1} & 1.806 & 2.402 & 0.596 & 2.361 & 0.409 & 0.555 & 1.791 & 0.014 & -0.610 \\  \hdashline
{2} & 2.131 & 2.655 & 0.524 & 2.609 & 0.046 & 0.478 & 2.156 & -0.025 & -0.500 \\  \hdashline
{3} & 2.368 & 2.854 & 0.485 & 2.815 & 0.039 & 0.446 & 2.412 & -0.043 & -0.442 \\  \hdashline
\bottomrule
\end{tabular}
\end{table}

\end{landscape}  
\end{document}

Best Answer

i don't see why those table should be in landscape orientation sine bot is easy to set in portrait orientation (with small changes of table design):

enter image description here

\documentclass[12pt]{article}
\usepackage[margin=1in,includefoot]{geometry}

\usepackage{mathtools}
\usepackage{siunitx}
\usepackage{array,
            booktabs, makecell, multirow, tabularx}
\renewcommand\theadfont{\bfseries\small}
\usepackage{dcolumn}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage{pdflscape}
\usepackage{afterpage}

\usepackage{showframe}
\begin{document}
    \thispagestyle{empty}

\begin{table}[ht]
    \centering
\caption{Oaxaca Blinder Decomposition results}
\begin{tabular*}{\linewidth}
                {@{\extracolsep{\fill}}
                l*{6}{S[table-format=-2.2]} }
    \toprule
\label{tab:oaxaca}
    & \multicolumn{3}{c}{2011-12} & \multicolumn{3}{c}{2004-05} \\
   \cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){5-7}
\thead[b]{Terms of \\ decomposition}
    & {\thead[b]{women\\ ws}}   & {\thead[b]{male\\ ws}}  & {\thead[b]{pooled\\ ws}}
    & {\thead[b]{women\\ ws}}   & {\thead[b]{male\\ ws}}  & {\thead[b]{pooled\\ ws}} \\ \midrule
Difference  & 0.39  & 0.39  & 0.39  &  0.48 &  0.48 & 0.48 \\ \hdashline
Explained   & -0.02 & 0.00  & -0.01 &  0.07 &  0.10 & 0.09 \\ \hdashline
Unexplained & 0.48  & 0.39  & 0.40  &  0.41 &  0.37 & 0.38 \\
    \midrule
\textbf{Unexplained} (\%)
            & 102.95 & 98.42& 99.62 & 85.42 & 78.88 & 79.49 \\
 \bottomrule
  \end{tabular*}
\end{table}

or

\begin{table}[ht] \centering
\caption{Oaxaca Blinder Decomposition results}
\begin{tabular}{l*{6}{S[table-format=-1.2]} }
    \toprule
\label{tab:oaxaca}
\multirow{2}{*}{\thead[b]{Terms of \\ decomposition}}
    & \multicolumn{3}{c}{2011-12} & \multicolumn{3}{c}{2004-05} \\
   \cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){5-7}
    & \textbf{women}    & \textbf{male} & \textbf{pooled}
    & \textbf{women}    & \textbf{male} & \textbf{pooled}   \\ \midrule
Difference  & 0.39  & 0.39  & 0.39  &  0.48 &  0.48 & 0.48  \\ \hdashline
Explained   & -0.02 & 0.00  & -0.01 &  0.07 &  0.10 & 0.09  \\ \hdashline
Unexplained & 0.48  & 0.39  & 0.40  &  0.41 &  0.37 & 0.38  \\
    \midrule
\textbf{Unexplained} (\%)
            & 102.95 & 98.42& 99.62 & 85.42 & 78.88 & 79.49 \\
 \bottomrule
  \end{tabular}
\end{table}

\begin{table}[ht]
    \centering
    \setlength\tabcolsep{0pt}
\caption{MMM Decomposition results}
    \begin{tabular*}{ \linewidth}{@{\extracolsep{\fill}}
                                  l*{9}{S[table-format=-1.3]}
                                  }
    \toprule
\textbf{Deciles} & \textbf{Men} & \textbf{Women} & \textbf{Diff.} & \multicolumn{3}{c}{Returns to women} & \multicolumn{3}{c}{Returns to men}   \\
 \cmidrule(lr){5-7}\cmidrule(lr){8-10}
    &  &  &  & {CF1} & {Charac} & {Coeff} & {CF2} & {Charac} & {Coeff}      \\
    \midrule
\multicolumn{10}{l}{Panel A: 2011-12} \\
    \midrule
{1} & 1.806 & 2.402 & 0.596 & 2.361 & 0.409 & 0.555 & 1.791 & 0.014 & -0.610 \\  \hdashline
{2} & 2.131 & 2.655 & 0.524 & 2.609 & 0.046 & 0.478 & 2.156 & -0.025 & -0.500 \\  \hdashline
{3} & 2.368 & 2.854 & 0.485 & 2.815 & 0.039 & 0.446 & 2.412 & -0.043 & -0.442 \\  \bottomrule
\end{tabular*}
\end{table}

%\end{landscape}
\end{document}

note: meaning of ws in the first table is unknown to me. i would remove them (as is shown in second example of tables) and its meaning explain in text or in table caption.

addendum: as follows from op comment below, tables had to be in landscape orientation and should be the same width as is text in this orientation ...

enter image description here

\documentclass[12pt]{article}
\usepackage[margin=1in,includefoot]{geometry}
\usepackage{pdflscape}
\usepackage{afterpage}

\usepackage{siunitx}
\usepackage{booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}

\begin{document}
    \thispagestyle{empty}
    \afterpage{\clearpage}
\begin{landscape}
\noindent%
\verb+x - - -+ \hfill \verb+- - -+ indicate text width in landscape orientation \verb+- - -+ \hfill \verb+- - - x+

\begin{table}[ht]
    \centering
\caption{Oaxaca Blinder Decomposition results}
\begin{tabular*}{\linewidth}
                {@{\extracolsep{\fill}}
                l*{6}{S[table-format=-2.2]} }
    \toprule
\label{tab:oaxaca}
    & \multicolumn{3}{c}{2011-12} & \multicolumn{3}{c}{2004-05} \\
   \cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){5-7}
\thead[b]{Terms of decomposition}
    & {\thead[b]{women ws}}   & {\thead[b]{male ws}}  & {\thead[b]{pooled ws}}
    & {\thead[b]{women ws}}   & {\thead[b]{male ws}}  & {\thead[b]{pooled ws}}    \\ \midrule
Difference  & 0.39  & 0.39  & 0.39  &  0.48 &  0.48 & 0.48 \\ 
Explained   & -0.02 & 0.00  & -0.01 &  0.07 &  0.10 & 0.09 \\
Unexplained & 0.48  & 0.39  & 0.40  &  0.41 &  0.37 & 0.38 \\
    \midrule
\textbf{Unexplained} (\%)
            & 102.95 & 98.42& 99.62 & 85.42 & 78.88 & 79.49 \\
    \bottomrule
\end{tabular*}
    \end{table}

\begin{table}[ht]
    \centering
    \setlength\tabcolsep{0pt}
\caption{MMM Decomposition results}
    \begin{tabular*}{ \linewidth}{@{\extracolsep{\fill}}
                                  l*{9}{S[table-format=-1.3]}
                                  }
    \toprule
\textbf{Deciles} & {\textbf{Men}} & {\textbf{Women}} & {\textbf{Difference}} & \multicolumn{3}{c}{Returns to women} & \multicolumn{3}{c}{Returns to men}   \\
 \cmidrule(l){5-7}\cmidrule(l){8-10}
    &  &  &  & {CF1} & {Charac} & {Coeff} & {CF2} & {Charac} & {Coeff}      \\
    \midrule
 Panel A: 2011-12    &  \multicolumn{9}{c}{}                                     \\
    \midrule
{1} & 1.806 & 2.402 & 0.596 & 2.361 & 0.409 & 0.555 & 1.791 & 0.014 & -0.610 \\
{2} & 2.131 & 2.655 & 0.524 & 2.609 & 0.046 & 0.478 & 2.156 & -0.025 & -0.500 \\
{3} & 2.368 & 2.854 & 0.485 & 2.815 & 0.039 & 0.446 & 2.412 & -0.043 & -0.442 \\  \bottomrule
\end{tabular*}
    \end{table}
\end{landscape}
\end{document}