1

i have a problem to get the section heading on the same page as my table. Any idea to solve this problem? Here is my (shortened) code:

\documentclass[a4paper, 12pt, twoside=true, openright, headsepline, pointlessnumbers]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,ngerman]{babel}

\usepackage[backend=bibtex,style=alphabetic]{biblatex}
\addbibresource{citavi_lit.bib}

\usepackage{longtable}
\usepackage{lscape}
\usepackage{booktabs}

\begin{document}
\section{Test section}
\ref{tab:test} is a landscape longtable
\begin{landscape}
\begin{longtable}{lll}
    \caption{test}\\
    \label{tab:test}\\\toprule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    1           & 2             3            \\\bottomrule
\end{longtable}
\end{landscape}
\end{document}
6
  • just put the section heading inside the landscape, also longtable has no [H] option (I really should make that give an error) Sep 26, 2018 at 14:28
  • It is much easier for people to help if your example code is a complete small document that shows the problem. Your fragment can't be run and uses several commands not defined by default, \pictureref for example, but also \toprule, landscape and longtable (although I could guess which packages you used for those) Sep 26, 2018 at 14:31
  • @DavidCarlisle I tried this before but i don't want heading sideways. Also I edited my code. Now it should be complete.
    – DanielV
    Sep 27, 2018 at 6:21
  • If you really want the heading rotated put it in the longtable, in a \rotatebox{-90}{\parbox{5cm}{\section{...}}} but I don't think I'd do that. Sep 27, 2018 at 6:47
  • No, i don't want to the heading rotated. Heading should be horizontal.I want only the table rotated but i need the longtable because the table needs 3 pages.
    – DanielV
    Sep 27, 2018 at 7:15

1 Answer 1

3

You need to make sure that the table is not so wide that there is no room for the section head, but if there is room you can position a heading in the space, if you need that

enter image description here

\documentclass[a4paper, 12pt, twoside=true, openright, headsepline, pointlessnumbers]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,ngerman]{babel}

\usepackage[backend=bibtex,style=alphabetic]{biblatex}
\addbibresource{citavi_lit.bib}

\usepackage{longtable}
\usepackage{lscape}
\usepackage{booktabs}

\begin{document}

\begin{landscape}
\begin{picture}(0,0)
\put(550,10){\rotatebox{-90}{\parbox{5cm}{\section{Test section}}}}
\end{picture}
\begin{longtable}{lll}
    \caption{test}\\
    \label{tab:test}\\\toprule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    \textbf{1}  & \textbf{2}    & \textbf{3} \\\midrule
    1           & 2             3            \\\bottomrule
\end{longtable}

\ref{tab:test}
\end{landscape}
\end{document}
1
  • The solution with rotatebox is great, thank you!
    – Firebug
    Feb 11, 2021 at 12:35

You must log in to answer this question.

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