[Tex/LaTex] KOMA landscape/portrait

koma-scriptlandscape

Got an problem regarding landscape pages in a portrait report.
The first sheet is according to the koma manual and works fine. The second with the same code won't.

Example:

\documentclass[ 12pt,                   
                paper=a4,               
                pagesize,               
                DIV=calc,               
                liststotocnumbered,     
                headsepline,            
                footsepline]            
                {scrreprt}

\usepackage[left=1.5cm,right=1.5cm,top=1cm,bottom=1cm,includeheadfoot]{geometry}

%langue settings
%header and footer settings

\begin{document}

First page in portrait\\

\storeareas\myvalues
\KOMAoptions{pagesize, paper=landscape, DIV=20} 
Second page in landscape\\
\clearpage
\myvalues

Third page in portrait again\\

\KOMAoptions{pagesize, paper=landscape, DIV=20} 
Fourth page NOT in landscape!!!!\\
\clearpage

\end{document}

Some ideas?

best regards

Best Answer

This seems like a bug to me, involving a conflict between the storeareas command and the KOMAoptions. Here are a few workarounds.

I have simplified the example a little. The one change I have made is to add a clearpage after each page. Otherwise, in some cases the wrong page is affected or pages are joined together.

You can get it to work by using a second storeareas command:

\documentclass[pagesize,paper=a4]{scrreprt}
\begin{document}

First page in portrait\\
\clearpage

\storeareas\myvalues
\KOMAoptions{pagesize,paper=landscape,DIV=20}
\storeareas\landscapevalues
Second page in landscape\\
\clearpage

\myvalues
Third page in portrait again\\
\clearpage

\landscapevalues
Fourth page IS in landscape!!!!\\

\end{document}

Or, you can scrap the storeareas command altogether:

\documentclass[pagesize,paper=a4]{scrreprt}
\begin{document}

First page in portrait\\
\clearpage

\KOMAoptions{pagesize,paper=landscape,DIV=20}
Second page in landscape\\
\clearpage

\KOMAoptions{pagesize,paper=portrait,DIV=calc}
Third page in portrait again\\
\clearpage

\KOMAoptions{pagesize,paper=landscape,DIV=20}
Fourth page IS in landscape!!!!\\

\end{document}

The simplest change is hacky and shows how fragile things are. You can change the paper "back" to a4 right before the second landscape declaration. (It actually also works to simply change the second paper=landscape to paper=a4, but this seems even hackier.)

\documentclass[pagesize,paper=a4]{scrreprt}
\begin{document}

First page in portrait\\
\clearpage

\storeareas\myvalues
\KOMAoptions{pagesize,paper=landscape,DIV=20}
Second page in landscape\\
\clearpage

\myvalues
Third page in portrait again\\
\clearpage

\KOMAoptions{paper=a4}
\KOMAoptions{pagesize, paper=landscape,DIV=20}
Fourth page IS in landscape!!!!\\

\end{document}
Related Question