[Tex/LaTex] How to translate and rotate the heading of landscaped pages

header-footerlandscaperotating

Objective

How to change the heading of landscaped pages from

alt text

to

alt text

?

Minimal Code

\documentclass{book}
\usepackage[a5paper,hmargin=3cm,vmargin=5cm]{geometry}
\usepackage{lscape,lipsum}

\begin{document}
\chapter{One}
\lipsum[1]

\section{One One}
\lipsum[2]

\newgeometry{hmargin=5cm,vmargin=3cm}

\begin{landscape}
\lipsum[3-5]
\end{landscape}

\restoregeometry
\lipsum[6]

\end{document}

Edit 1 (my real scenario layout)

In my real scenario, the left-right margins should not be occupied by headings.

alt text

Best Answer

The lscape package is not designed for this. It's designed for rotating wide figures or tables, for example. And the geometry package explicitly says that \newgeometry can't change the paper size or orientation. So I don't think there's a way to do this automatically.

You can include landscape oriented pdf pages using the pdfpages package. (Include them with the [landscape] option.)

A new solution

You could also use the textpos package to place the headers. By combining this with the fancyhdr package, you can pretty much automate it.

\documentclass[twoside]{book}
\usepackage[a5paper,hmargin=3cm,vmargin=5cm]{geometry}
\usepackage{lscape,lipsum,graphicx}
\usepackage[absolute]{textpos}
\usepackage{fancyhdr}

\fancypagestyle{lscape}{% 
\fancyhf{} % clear all header and footer fields 
\fancyfoot[LE]{%
\begin{textblock}{20}(1,5){\rotatebox{90}{\leftmark}}\end{textblock}
\begin{textblock}{1}(13,10.5){\rotatebox{90}{\thepage}}\end{textblock}}
\fancyfoot[LO] {%
\begin{textblock}{1}(13,10.5){\rotatebox{90}{\thepage}}\end{textblock}
\begin{textblock}{20}(1,13.25){\rotatebox{90}{\rightmark}}\end{textblock}}
\renewcommand{\headrulewidth}{0pt} 
\renewcommand{\footrulewidth}{0pt}}

\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}

\begin{document}
\chapter{A chapter}
\section{A section}
\lipsum
\section{A section}
\lipsum

\newgeometry{hmargin=3cm,vmargin=5cm}
\thispagestyle{lscape}
\pagestyle{lscape}
\begin{landscape}
\lipsum[1-3]

\end{landscape}

\restoregeometry
\pagestyle{headings}
\lipsum[6]

\end{document}