1

The appendix of my thesis contains some large tables which I create using the sideways environment. As, in the appendix, every table is an own section, I include the section-command within the sideways environment so that it appears on the same page and is rotated in the same way as the table. This works fine. However, the header of the page does not change, but still shows the previous section.

\documentclass{scrbook}
\usepackage[automark, headsepline]{scrlayer-scrpage}
\usepackage{rotating}

\begin{document}

\section{Section 1}

\begin{sidewaystable}
\section{Section 2}
    % tabularx
\end{sidewaystable}

\begin{sidewaystable}
\section{Section 3}
    % tabularx
\end{sidewaystable}`

\end{document}

Page 3 of this example shows "Section 1" in the header instead of "Section 3". How can I fix that?

  • Don't put \section inside sidewaystable (which is a float). You need landscape environment instead. – user11232 Oct 4 '15 at 2:11
2

At last it depends on your tables. In the following MWE I show you several possibility's. Please check which one is the best for you.

  • In section 2 I used environment landscape (package pdflscape), that used an separate page for the table,
  • in section 3 I used command \ctable (package ctable), that shows the table on an own page and
  • in section 4 I used environment adjustbox (package adjustbox), which does not use a separate page (see the options I used!).

You can see that there is no need to include the command \section into an environment as you did with \sidewaystable. The \section command is the marker for the header to change the content. A sidewaystable is a float, that means LaTeX is allowed to move it to the next page for example. In your case (\section inside sideways table) the section heading was also moved.

The documentation for the used packages can you read with texdoc package name on the console/terminal. For example texdoc ctable for package ctable.

The MWE:

\documentclass{scrbook}
\usepackage[automark, headsepline]{scrlayer-scrpage}
%\usepackage{rotating}% for sidewaystable
\usepackage{pdflscape}%  for landscape
\usepackage{blindtext}%  to create a dummy document/text
\usepackage{ctable}   %  table rotated on complete page
\usepackage{adjustbox}%  no own page!
\usepackage{caption}  % for \captionof{table}{text}

\begin{document}

\section{Section 1}
\Blindtext

\section{Section 2}
\Blindtext
\begin{landscape}
  \captionof{table}{Test table section 2}
  \begin{tabular}{lll}
    Column 1/2 & Column 2 & Column 3 \\
    Row 2, 1   & Row 2, 2 & Row 2, 3 \\
    Row 3, 1   & Row 3, 2 & Row 3, 3 
  \end{tabular}
\end{landscape}
\Blindtext

\section{Section 3}
\ctable[%
  caption={Test table section 3},
  label={tab:testtable},
  botcap, %  caption below table
  sideways % This rotates the table
]{ccc}
{
% Table footnotes here, see ctable docs
}
{
  Column 1/3 & Column 2 & Column 3 \\
  Row 2, 1   & Row 2, 2 & Row 2, 3 \\
  Row 3, 1   & Row 3, 2 & Row 3, 3 \\
}
\blindtext

\section{Section 4}
\blindtext

\begin{adjustbox}{angle=90,center,caption={Test table section 4},nofloat=table}
  \begin{tabular}{lll}
  Column 1/4 & Column 2 & Column 3 \\
  Row 2, 1   & Row 2, 2 & Row 2, 3 \\
  Row 3, 1   & Row 3, 2 & Row 3, 3 
  \end{tabular}
\end{adjustbox}

\blindtext
\end{document}

See the result for section 4:

enter image description here

  • Thank you so much!! I use the landscape option and only needed to replace sidewaystable with landscape. With the commands described here (tex.stackexchange.com/questions/2326/…), I ensure vertical alignment. – Martin Oct 4 '15 at 9:08

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.