0

I have a sidewaystable in an appendix and now I would like to insert headings on the page for better clarity. sidewaystable automatically causes a page break. So, I tried the rotate package which led to display errors:

table moves beyond the heading.

Could someone please help me inserting a heading on the page and immediately below the table?

\documentclass[a4paper]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{ragged2e}
\usepackage{everysel}
\usepackage{footmisc}
\usepackage{multirow} \usepackage{booktabs}
\usepackage{float}
\usepackage{threeparttable}
\usepackage[referable]{threeparttablex} \usepackage{pdflscape} \usepackage{lscape} \usepackage{tabularx} \usepackage{tabulary} \usepackage{longtable} \usepackage{afterpage}
\usepackage{tabu} \usepackage{adjustbox} \usepackage{array} \usepackage[figuresright]{rotating} \usepackage[section]{placeins}
\usepackage[format=hang, justification=RaggedRight,
singlelinecheck=off,
labelfont=bf,
font=footnotesize, textfont=footnotesize, twoside, labelsep=colon ]{caption}
\usepackage[language=autobib, backend=biber %%%% switch on/off ]{biblatex}

%%% Minitab \newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}} %%%

%%% Mod ThreePartTable \makeatletter \g@addto@macro\TPT@defaults{\scriptsize} \makeatother %%%

%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\section*{Section} \begin{sidewaystable} \begin{threeparttable} \caption[xxx] {\textbf{xxx}} \centering \small \begin{tabularx}{\textwidth} { X >{\raggedleft\arraybackslash}p{12ex} >{\raggedleft\arraybackslash}p{12ex} p{0.5ex} |
>{\raggedleft\arraybackslash}p{10.5ex} p{0.25ex} % >{\raggedleft\arraybackslash}p{12ex} >{\raggedleft\arraybackslash}p{12ex} p{0.5ex} |
>{\raggedleft\arraybackslash}p{10.5ex} p{0.25ex} % }

\toprule

& \multicolumn{4}{c}{group 1} & % & \multicolumn{4}{c}{group 2} & \

\cmidrule(lr){2-5} \cmidrule(lr){7-10}

& \multicolumn{3}{c}{yyy\tnote{a}}
& \multirow[b]{2}{}{\minitab[c]{zzz\rrr\tnote{b}}}
& % & \multicolumn{3}{c}{yyy\tnote{a}}
& \multirow[b]{2}{
}{\minitab[c]{zzz\rrr\tnote{c}}}
& % \

\cmidrule(lr){2-4} \cmidrule(lr){7-9}

& n & %
& & & % & n & % & & &

\

\midrule xxx & 20 & 24,4% && 80,0,% & & 24 & 23,5,% && 85,7,% & \

\midrule Total & 82 & 100,0,% && 328,0,% & & 102 & 100,0,% && 364,3,% & \

\bottomrule \end{tabularx} %%%%%%%%%%%%%%%%% \begin{tablenotes} \scriptsize \justifying \RaggedRight \item[a] AAAAAAA \end{tablenotes} %%%%%%%%%%%%%%%%% \end{threeparttable} \end{sidewaystable}

\end{document}

enter image description here enter image description here

Werner
  • 603,163
TRJW
  • 450
  • Do you really need the spaces in column width fixing by p{}? Reducing spaces can solve it, i think. – mmr Nov 24 '21 at 00:19
  • Hi mmr, the spaces are needed and NO, reducing spaces does NOT solve the problem. – TRJW Nov 24 '21 at 08:07

1 Answers1

1

Below I forego the use of threeparttable, setting the \tnotes as \textsuperscript. The important, structural thing is to use the following setup:

\begin{center}% Center table horizontally
  \rotatebox{90}{% Rotate table 90 degrees (anti-clockwise)
    % In order to rotate something, it's often best to place it inside a box-like structure,
    % like a minipage
    \begin{minipage}{\textwidth}
      % With the float package, you can turn a float into a non-float via the [H]ERE
      % float specifier. This is needed because you're placing the float inside a box (a
      % minipage), yet want float-like capabilities (like \caption).
      \begin{table}[H]
        <your table>
      \end{table}
    \end{minipage}%
  }
\end{center}

Here's a complete working example:

enter image description here

\documentclass[a4paper]{scrbook}

\usepackage{ragged2e} \usepackage{multirow} \usepackage{booktabs,graphicx} \usepackage{tabularx,float} \usepackage{array}

\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}} \newcommand{\tnote}{\textsuperscript}

\begin{document}

\section*{Section}

\begin{center} \rotatebox{90}{% \begin{minipage}{\textwidth} \begin{table}[H] \centering \small \caption[xxx]{\bfseries xxx} \begin{tabularx}{\textwidth}{ X >{\raggedleft\arraybackslash}p{12ex} >{\raggedleft\arraybackslash}p{12ex} p{0.5ex} |
>{\raggedleft\arraybackslash}p{10.5ex} p{0.25ex} % >{\raggedleft\arraybackslash}p{12ex} >{\raggedleft\arraybackslash}p{12ex} p{0.5ex} |
>{\raggedleft\arraybackslash}p{10.5ex} p{0.25ex} % } \toprule & \multicolumn{4}{c}{group 1} & % & \multicolumn{4}{c}{group 2} & \

      \cmidrule(lr){2-5} 
      \cmidrule(lr){7-10}

      &amp; \multicolumn{3}{c}{yyy\tnote{a}}
      &amp; \multirow[b]{2}{*}{\minitab[c]{zzz\\rrr\tnote{b}}}
      &amp;
      %
      &amp; \multicolumn{3}{c}{yyy\tnote{a}}
      &amp; \multirow[b]{2}{*}{\minitab[c]{zzz\\rrr\tnote{c}}}
      &amp;
      %
      \\

      \cmidrule(lr){2-4}
      \cmidrule(lr){7-9}


      &amp; n 
      &amp; \%        
      &amp; 
      &amp;
      &amp;
      %
      &amp; n
      &amp; \%
      &amp; 
      &amp;
      &amp;

      \\

      \midrule
      xxx         &amp;   20      &amp;   24,4\%      &amp;&amp;  80,0\,\%    &amp;
                      &amp;   24      &amp;   23,5\,\%        &amp;&amp;  85,7\,\%    &amp;
                      \\

      \midrule
      Total           &amp;   82      &amp;   100,0\,\%       &amp;&amp;  328,0\,\%   &amp;
                      &amp;   102     &amp;   100,0\,\%       &amp;&amp;  364,3\,\%   &amp;
                      \\

      \bottomrule
    \end{tabularx}

    \scriptsize
    \RaggedRight
    \tnote{a} AAAAAAA
  \end{table}%
\end{minipage}

} \end{center}

\end{document}

Werner
  • 603,163
  • I thank you very much. Was a little bit surprised that this issue was caused by Tabularx. – TRJW Dec 14 '21 at 17:50