# Objective

How to change the heading of landscaped pages from

to

?

# 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.

-
Page headings and numbers support browsing and look-up in a book, that's why I think they should remain like on portrait pages resp. the standard layout. They are not page-specific decoration. I don't like to turn a book to landscape and back while looking for a section or a page number. –  Stefan Kottwitz Jan 16 '11 at 14:54
@Stefan: But this heading will disturb my landscaped pages. On the landscaped pages I have a long table. The left-right margin should not be consumed by heading. –  xport Jan 16 '11 at 15:00
In that case I suggest to use an empty page style. –  Stefan Kottwitz Jan 16 '11 at 15:17
@Stefan: I already tried it. But I need page numbers. :-) –  xport Jan 16 '11 at 15:33
@xport: Then try \thispagestyle{plain} or something similar. –  Leo Liu Jan 16 '11 at 17:18

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{\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
\lipsum[6]

\end{document}

-
@Alan: Thanks for answering. Unfortunately, my scenario does not match your suggestion. There is no pdf page to be imported. And I don't want to create such pdf because it is tedious job. –  xport Jan 16 '11 at 14:54
@xport I added a different solution. Maybe that will work for you. –  Alan Munn Jan 16 '11 at 17:50
@Alan: This should work. The code seems to be pasted twice. Furthermore, \thispagestyle{lscape} is enough, \pagestyle{lscape} may be deleted. (and \newgeometry may be deleted?) –  Leo Liu Jan 16 '11 at 17:57
@Leo Thanks for catching the duplicate code. No, I don't think the \pagestyle command can be removed, since we need any subsequent landscape pages to be that pagestyle too. The \newgeometry command was in xport's original example; it's needed so that the landscape pages have the right size. –  Alan Munn Jan 16 '11 at 18:31
@Alan: heading and page number should be at top right and bottom center, respectively. Your settings does not match a bit. –  xport Jan 16 '11 at 22:50

I need page numbers on the landscaped pages. And the page numbers should be at the bottom as shown in the second figure above.

I have an idea. We can use \fancypagestyle to define a new pagestyle with landscaped page numbers. I use tikz to put the page number.

\fancypagestyle{lscapedplain}{%
\fancyhf{}
\fancyfoot{%
\tikz[remember picture,overlay]
\node[outer sep=1cm,above,rotate=90] at (current page.east) {\thepage};}
}


This would also be done by \newpagestyle from titlesec.

-
I accidentally undid my vote on your answer. If you edit your answer, I can upvote it again. :-) –  Alan Munn Jan 16 '11 at 18:32
@Alan: I think the code here shows the key to the question. (So does yours.) @xport can do the rest herself. Never mind about voting. –  Leo Liu Jan 17 '11 at 4:56
Leo: I came back to this question to solve a problem that a student discovered with my thesis class, so now I've finally got around to voting for this question again. I'm actually going to include it into my thesis class; it's a very nice solution. Thanks. –  Alan Munn Aug 25 '11 at 0:05
This solution worked for me, but I had to add the \usepackage{tikz} to my document preamble. It also added a vertical line on the right side of my landscape-d page, which I had to get rid of using: \renewcommand{\headrulewidth}{0pt} –  John Mark Jan 7 at 16:23