2

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}
  • 1
    please make your mwe shorter. remove all what is not necessary to set a table. also make clear, if you like to have table in portrait oriented page or in landscape orientation? – Zarko Sep 6 '17 at 18:40
  • @Zarko just did that. – Kusha Verma Sep 6 '17 at 18:44
3

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}
| improve this answer | |
  • I need the table to be in landscape from since the tables preceding these tables are in landscape and I need a continuation of orientation. – Kusha Verma Sep 6 '17 at 19:32
  • @KushaVerma, and what is then problem? your table is in landscape orientation (to my taste not look nice, but this doesn't topic of your question). how to fit to text border you can see in given examples in my answer (with this they will look more terrible, again to my taste :-( ... i will show example in addendum to my answer. – Zarko Sep 6 '17 at 19:43
1

You can also try tabularx:

\begin{tabularx}{\hsize}{<column specs>}
...
\end{tabularx}

Here is your complete example using this approach:

\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[fleqn]{amsmath}
\usepackage{mathtools}
\usepackage{siunitx}

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

\addtolength{\parskip}{\baselineskip}

\begin{document} 
\begin{landscape}
  \begin{table}[ht] \centering
    \caption{Oaxaca Blinder Decomposition results}
    \begin{tabularx}{\hsize}{ Xl*{5}{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{tabularx}
  \end{table}

  %\clearpage

  \begin{table}[ht] \centering
    \caption{MMM Decomposition results}
    \begin{tabularx}{\hsize}{ Xl*{8}{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{tabularx}
  \end{table}
\end{landscape}  
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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