2

I have a oversized sidewaystable, that means I have too many rows for my geometry. The oversize prevents my table from appearing on a page with the section. Here is a small example. The section isn't on the same page as the table.

\documentclass[fontsize=12pt, paper=a4, oneside, headsepline]{scrbook}
\usepackage{scrpage2}
\pagestyle{scrheadings}
\usepackage[top=3cm, bottom = 3cm, left =3.5cm, right=2cm]{geometry}
\usepackage{caption, booktabs}
\usepackage[figuresright]{rotating}
\usepackage{siunitx}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\usepackage{float}

\begin{document}
\section{Testsection}
\begin{sidewaystable}
\centering
\captionof{table}{Test: Oversized sidewaystable} 
\addtolength{\tabcolsep}{-2pt}
\begin{tabular}{
  |l|l|S|S|S|S|S|S|S| *{7}{S[table-format=-1.3,table-space-text-post=***]}
}

\hline

\textbf{test1} & {\textbf{test2}} & {\textbf{Number1}} & {\textbf{Number2}} & 
                {\textbf{Number3}} & {\textbf{Number4}} & {\textbf{Number5}} & {\textbf{Number6}} & {\textbf{Number7}} \\ 

\hline\hline 
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\ 
\hline 
\end{tabular} 
\end{sidewaystable}
\end{document}

Here is my question: How can I get the table on the same page as the section? I've tried to use [H] like:

\begin{sidewaystable}[H]

But this made the whole table disappear.

Does anyone have a solution for my problem?

Many thanks in advance.

Philippe

2

Two ways for this: either you set the font size to \footnotesize and use a smaller value of \tabcolsep, and you don't need sidewaystable. Or you use a minipage nested in a sideways environment.

Note compilation produces a warning about scrpage2 being obsolete and having to be replaced with scrlayer-scrpage, which I did.

\documentclass[fontsize=12pt, paper=a4, oneside, headsepline]{scrbook}
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\usepackage[vmargin= 3cm, left =3.5cm, right=2cm, showframe]{geometry}
\usepackage{caption, booktabs}
\usepackage[figuresright]{rotating}
\usepackage{siunitx}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\usepackage{float}

\begin{document}
\setcounter{chapter}{1}

\section{Testsection}

\begin{table}[!htb]%sidewaystable
\centering
\captionabove{Test: Oversized sidewaystable}
\setlength{\tabcolsep}{3pt}\footnotesize
\begin{tabular}{
  |l|l| *{7}{S[table-format=-1.3,table-space-text-post=***]|}
}

\hline

\textbf{test1} & {\textbf{test2}} & {\textbf{Number1}} & {\textbf{Number2}} &
                {\textbf{Number3}} & {\textbf{Number4}} & {\textbf{Number5}} & {\textbf{Number6}} & {\textbf{Number7}} \\

\hline\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
\end{tabular}
\end{table}

\clearpage
\section{Testsection}

\begin{sideways}%
\setlength{\tabcolsep}{3pt}
\setlength{\belowcaptionskip}{2ex}
\begin{minipage}{1.12\textwidth}
\small
\captionaboveof{table}{Test: Oversized sidewaystable}
\begin{tabular}{
  |l|l| *{7}{S[table-format=-1.3,table-space-text-post=***]|}
}
\hline
\textbf{test1} & {\textbf{test2}} & {\textbf{Number1}} & {\textbf{Number2}} &
               {\textbf{Number3}} & {\textbf{Number4}} & {\textbf{Number5}} & {\textbf{Number6}} & {\textbf{Number7}} \\
\hline\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
test1 & test2 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\hline
\end{tabular}
\end{minipage}
\end{sideways}
\end{document} 

enter image description here enter image description here

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.