1

I have the following problem. I have the following code and now I want to achieve that the table is not shown on a new page, but under the section heading, so that the table is shortened vertically a bit. How do I do this?

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{multirow}
\usepackage{float}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{multicol}
\usepackage{booktabs}
\begin{document}
\section{A}
\begin{sidewaystable}
    \centering
    \caption{Caption}
    \begin{adjustbox}{width=1\textwidth}
        \begin{threeparttable}
            \begin{tabular}{@{}lcccccccccccccccccccccc@{}}
                    \toprule \toprule 
                                        & & & & & & & &&&&&&&&&&&&&&&
\\\multicolumn{23}{c}{\textbf{Modell 1}}\\
                    \midrule
                    & \multicolumn{3}{c}{$T=4$} & \multicolumn{3}{c}{$T=8$} & \multicolumn{3}{c}{$T=12$} & \multicolumn{3}{c}{$T=16$} & \multicolumn{3}{c}{$T=20$} & \multicolumn{3}{c}{$T=24$} & \multicolumn{3}{c}{$T=28$}  \\
                    \cmidrule(lr){2-4}  \cmidrule(lr){5-7} \cmidrule(lr){8-10} \cmidrule(lr){11-13} \cmidrule(lr){14-16} \cmidrule(lr){17-19}
                    \cmidrule(lr){20-22}
                    & Min & Median & Max & Min & Median & Max & Min & Median & Max & Min & Median & Max & Min & Median & Max & Min & Median & Max & Min & Median & Max \\
                    \midrule
&I&A&A&S&D&F&C&D&W&Q&D&F&C&C&C&C&C&C&C&C&C&\\
                    &&&&&&&&&&&&&&&&&&&&&&\\
                    &&&&&&&&&&&&&&&&&&&&&&\\
                    &&&&&&&&&&&&&&&&&&&&&&\\                \midrule 
                    &&&&&&&&&&&&&&&&&&&&&&\\
                    \multicolumn{23}{c}{\textbf{Model 2}}\\
                    \midrule
                                        & \multicolumn{3}{c}{$T=4$} & \multicolumn{3}{c}{$T=8$} & \multicolumn{3}{c}{$T=12$} & \multicolumn{3}{c}{$T=16$} & \multicolumn{3}{c}{$T=20$} & \multicolumn{3}{c}{$T=24$} & \multicolumn{3}{c}{$T=28$}  \\
                    \cmidrule(lr){2-4}  \cmidrule(lr){5-7} \cmidrule(lr){8-10} \cmidrule(lr){11-13} \cmidrule(lr){14-16} \cmidrule(lr){17-19}
                    \cmidrule(lr){20-22}
                    & Min & Median & Max & Min & Median & Max & Min & Median & Max & Min & Median & Max & Min & Median & Max & Min & Median & Max & Min & Median & Max\\\midrule
                    &I&A&A&S&D&F&C&D&W&Q&D&F&C&C&C&C&C&C&C&C&C&\\
                    &&&&&&&&&&&&&&&&&&&&&&\\
                    &&&&&&&&&&&&&&&&&&&&&&\\
                    &&&&&&&&&&&&&&&&&&&&&&\\                    \bottomrule
                    \bottomrule
            \end{tabular}
                \begin{tablenotes}[para, flushleft]
                \vspace{0.1cm}
                \footnotesize \emph{Note:} 
            \end{tablenotes}
        \end{threeparttable}
    \end{adjustbox}
\end{sidewaystable}
\end{document}
1
  • Welcome to TeX.SE. Is placing the \section directive inside the sidewaystable environment an option for you?
    – Mico
    Sep 15, 2023 at 21:25

1 Answer 1

2

If placing the section inside the sidewaystable environment is an option for you, the following solution should be of interest to you. Note that it does not resort to the adjustbox visual sledgehammer to limit the width of the table to \textwidth. It doesn't double up on \toprule and \bottomrule statements either.

enter image description here

\documentclass[11pt]{article}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{booktabs}

\begin{document}

\begin{sidewaystable}
\section{A}

\begin{threeparttable}
\small % 10% linear reduction in font size
\setlength\tabcolsep{0pt}
\caption{Caption}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{21}{c} }
\\[1\baselineskip]
\multicolumn{21}{c}{\textbf{Modell 1}}\\[1ex]
\toprule
  \multicolumn{3}{c}{$T=4$}  & \multicolumn{3}{c}{$T=8$} 
& \multicolumn{3}{c}{$T=12$} & \multicolumn{3}{c}{$T=16$} 
& \multicolumn{3}{c}{$T=20$} & \multicolumn{3}{c}{$T=24$} 
& \multicolumn{3}{c}{$T=28$}  \\
\cmidrule{1-3}   \cmidrule{4-6}   \cmidrule{7-9} 
\cmidrule{10-12} \cmidrule{13-15} \cmidrule{16-18}
\cmidrule{19-21}
  Min & Med & Max & Min & Med & Max & Min & Med & Max 
& Min & Med & Max & Min & Med & Max & Min & Med & Max 
& Min & Med & Max \\
\midrule
I&A&A&S&D&F&C&D&W&Q&D&F&C&C&C&C&C&C&C&C&C\\
\bottomrule
 \\
 \\
\multicolumn{21}{c}{\textbf{Model 2}}\\[1ex]
\toprule
  \multicolumn{3}{c}{$T=4$}  & \multicolumn{3}{c}{$T=8$} 
& \multicolumn{3}{c}{$T=12$} & \multicolumn{3}{c}{$T=16$} 
& \multicolumn{3}{c}{$T=20$} & \multicolumn{3}{c}{$T=24$} 
& \multicolumn{3}{c}{$T=28$}  \\
\cmidrule{1-3}   \cmidrule{4-6}   \cmidrule{7-9} 
\cmidrule{10-12} \cmidrule{13-15} \cmidrule{16-18}
\cmidrule{19-21}
  Min & Med & Max & Min & Med & Max & Min & Med & Max 
& Min & Med & Max & Min & Med & Max & Min & Med & Max 
& Min & Med & Max\\
\midrule
I&A&A&S&D&F&C&D&W&Q&D&F&C&C&C&C&C&C&C&C&C\\
\bottomrule
\end{tabular*}

\bigskip
\begin{tablenotes}[para, flushleft]
\footnotesize 
\emph{Notes.} \dots
\end{tablenotes}
\end{threeparttable}

\end{sidewaystable}
\end{document}

You must log in to answer this question.

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