# Change page orientation inside document

I need to create a document with a title page, some introduction pages and a lot of tables. Those tables needs to be on landscape pages. So I need to switch the orientation on a certain page.

Also the borders should be very narrow, because I need a lot of space for the tables and documentation.

I found several solutions but non of them are working really good. Also the fancy header should continue on the landscape pages but should get the width of the page.

Here come one example:

\documentclass[a4paper,headsepline,footsepline]{report}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage[pdftex]{color}

\usepackage{typearea}
\usepackage{fancyhdr}

\usepackage{ngerman}

\usepackage{hyperref}
\setlength{\voffset}{-0.9in}
\setlength{\hoffset}{-0.9in}
\setlength{\textheight}{9.5in}
\setlength{\textwidth}{7in}
\setlength{\marginparwidth}{1in}

\pagestyle{fancy}
\fancyhf{}
\rfoot{Page \thepage}

\definecolor{cargosoft}{RGB}{1,107,181}

\newcommand{\myRule}[3][black]{\textcolor{#1}{\rule{#2}{#3}}}

\begin{document}

\begin{titlepage}
\centering
LOGO
{\scshape\LARGE Company name \par}
\vspace{1.5cm}
\myRule[cargosoft]{8cm}{0.4pt} \par
\vspace{0.5cm}
{\huge\bfseries document name\par}
\vspace{0.5cm}
\myRule[cargosoft]{8cm}{0.4pt} \par
\vspace{2cm}

\vfill

{\large \today\par}
\end{titlepage}

First page content comes here not in landscape

\KOMAoption{paper}{landscape}
\pagestyle{fancy}
\fancyhf{}
\rfoot{Page \thepage}

\areaset{\textwidth}{\textheight}
\recalctypearea
content on landscape pages
\end{document}


The next thing I tried comes from this post How to switch from portrait to landscape page orientation? The result is, that the page is in landscape, but the fancy header is not. Also the content is horizontal centered.

\documentclass[a4paper,headsepline,footsepline]{report}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage[pdftex]{color}
\usepackage[margin=0.5cm]{geometry}

\usepackage{typearea}
\usepackage{fancyhdr}

\usepackage{ngerman}

\usepackage{hyperref}

\usepackage{pdflscape}

\pagestyle{fancy}
\fancyhf{}
\rfoot{Page \thepage}

\definecolor{cargosoft}{RGB}{1,107,181}

\newcommand{\myRule}[3][black]{\textcolor{#1}{\rule{#2}{#3}}}

\begin{document}

\begin{titlepage}
\centering
LOGO
{\scshape\LARGE Company name \par}
\vspace{1.5cm}
\myRule[cargosoft]{8cm}{0.4pt} \par
\vspace{0.5cm}
{\huge\bfseries document name\par}
\vspace{0.5cm}
\myRule[cargosoft]{8cm}{0.4pt} \par
\vspace{2cm}

\vfill

{\large \today\par}
\end{titlepage}

First page content comes here not in landscape
\begin{landscape}
content on landscape pages
\end{landscape}
\end{document}


Does anyone has a good working solution for me?

Thanks a lot, Hauke

• Welcome to TeX.SX! Does the answers to How to switch from portrait to landscape page orientation? help? – Bobyandbob Aug 1 '17 at 15:23
• A convenient package for adjusting page margins is geometry. For example, \usepackage[margin=2cm]{geometry} will set all margins to 2 cm. You can also specify different vertical and horizontal margins (with keys hmargin and vmargin) and change the margins for individual pages. – Michael Palmer Aug 1 '17 at 15:33
• Yes I tried both. @Babyandbob: The page is in landscape, the content is centered and the header is turned around (its on the right vertical side). At Michael Palmer: Even if I change the margin to 0.5cm, it wont change anything. I edit my post with both examples. – Hauke Aug 1 '17 at 18:19
• I guess one should use either typearea or geometry, not both. – Michael Palmer Aug 1 '17 at 21:55
• Landscape preserves the text area etc. relative to the page, and things like fancyhdr and \marginpar do not expect such parameters to change. The exception is if the entire document in in landscape. You could create your own header and footer using everypage. Alas, tikzpagenodes does not handle landscape either (see tex.stackexchange.com/questions/226678/…). – John Kormylo Aug 1 '17 at 22:13

Here is a solution with typearea:

You can use the optional paramerter DIV=<value> to control the space for the text area.

For the header/footer a new pagestyle needs to be defined. It has to contain \headwidth=\textwidth to set the correct width for the landscape pages.

Before switching to landscape, a new page must be started. Without it, the new settings may affect the previous page.

And in order to make the viewer show the pages in landscape, \pdfpageheight and \pdfpagewidht must be set.

\documentclass[a4paper,headsepline,footsepline]{report}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage[pdftex]{color}

% uses DIV=8
\usepackage{typearea}
% set DIV to squeeze out more space for text area
%\usepackage[DIV=12]{typearea}
\usepackage{fancyhdr}

\usepackage{ngerman}

\usepackage{hyperref}

\pagestyle{fancy}
\fancyhf{}
\rfoot{Page \thepage}

% new pagestyle
\fancypagestyle{lscape}{%
% important, sets the width of head and foot to current textwidth
% not needed as long as header/footer parts don't change
%\fancyhf{}
%\rfoot{Page \thepage}
}

\definecolor{cargosoft}{RGB}{1,107,181}

\newcommand{\myRule}[3][black]{\textcolor{#1}{\rule{#2}{#3}}}

\begin{document}

\begin{titlepage}
\centering
LOGO
{\scshape\LARGE Company name \par}
\vspace{1.5cm}
\myRule[cargosoft]{8cm}{0.4pt} \par
\vspace{0.5cm}
{\huge\bfseries document name\par}
\vspace{0.5cm}
\myRule[cargosoft]{8cm}{0.4pt} \par
\vspace{2cm}

\vfill

{\large \today\par}
\end{titlepage}

First page content comes here not in landscape

% start new page before setting page layout,
% otherwise previous page is also affected
\newpage
\KOMAoption{paper}{landscape}%
\typearea{12}% sets new DIV
\recalctypearea
% needed to show page in landscape in viewer
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth
\pagestyle{lscape}%

content on landscape pages
\end{document}


typearea doesn't give you complete control over the margins. It set the page layout according to rules about the ratio of margins. If you need more control, geometry can be used. But it doesn't support switching to landscape mid document. However, there is a solution for this here. It's downside is, that it may stop working after an update of geometry.

Remark: in your first example you used the typearea package and then set up some lengths for the page layout manually, and in you second example you loaded first geometry and then typearea. Both is not a good idea. In the second case typearea overwrites all settings done with geometry.

• Thanks for the explanation. It works great. After setting the correct DIV value, it looks like it should. – Hauke Aug 2 '17 at 5:39

With KOMA-Script version 3.17 or newer you can set option usegeometry for package typearea and then change the margins using package geometry:

\documentclass[a4paper,headsepline]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{color}
\usepackage[ngerman]{babel}

\usepackage[usegeometry]{typearea}
\usepackage[hmargin=.65in,vmargin=1.1in]{geometry}
\usepackage[manualmark]{scrlayer-scrpage}
\clearpairofpagestyles
\ofoot*{\pagemark}

\usepackage{hyperref}

\definecolor{cargosoft}{RGB}{1,107,181}
\newcommand{\myRule}[3][black]{\textcolor{#1}{\rule{#2}{#3}}}

\usepackage{blindtext}% only for dummy text

\begin{document}
\begin{titlepage}
\centering
LOGO
{\scshape\LARGE Company name \par}
\vspace{1.5cm}
\myRule[cargosoft]{8cm}{0.4pt} \par
\vspace{0.5cm}
{\huge\bfseries document name\par}
\vspace{0.5cm}
\myRule[cargosoft]{8cm}{0.4pt} \par
\vspace{2cm}
\vfill
{\large \today\par}
\end{titlepage}

\Blindtext

\cleardoublepage
\KOMAoptions{paper=landscape}
\recalctypearea
\newgeometry{hmargin=.65in,vmargin=1.1in}
\Blindtext

\end{document}


Result: