# 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: In printing you should definitely follow Stefan's advice and leave the page numbers in their usual places. Really!! Your screenshot shows that for screen reading it would indeed be good to move (and rotate) the page numbers. – Hendrik Vogt Jan 17 '11 at 12:59

## 5 Answers

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}

• @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 '15 at 16:23
• Nice lightweight solution! Can the size of the number be changed somehow? – Kalle Nov 27 '19 at 17:18

Analternative approach using package typearea to switch to landscape-mode mid-document. Though it is really strange to do that.

\documentclass[usegeometry,paper=a5,pagesize,headinclude]{book}
\usepackage{typearea}
\usepackage{lipsum}

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

\section{One One}
\lipsum[2]

\storeareas\normalsetting
\KOMAoption{paper}{landscape}
\areaset{2\textwidth}{.9\textheight}
\recalctypearea
\lipsum[3-5]
\clearpage
\normalsetting
\lipsum[6]

\end{document}


This method is answered by @Leo Liu, from http://bbs.ctex.org/forum.php?mod=viewthread&tid=78285.

Limited by the geometry package itself:

Unlike \geometry in the preamble,\newgeometry is available only after \begin{document}, resets all the options ever speciﬁed except for the papersize-related options: landscape, portrait, and paper size options (such as papersize, paper=a4paper and so forth), which can’t be changed with \newgeometry.

-- Geometry package manual

Make a patch so that the \newgeometry command uses the landscape and portrait options.

\usepackage{etoolbox}

\makeatletter
\def\ifGm@preamble#1{\@firstofone}
\appto\restoregeometry{%
\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight}
\apptocmd\newgeometry{%
\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight}{}{}
\makeatother


Complete example:

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

\makeatletter
\def\ifGm@preamble#1{\@firstofone}
\appto\restoregeometry{%
\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight}
\apptocmd\newgeometry{%
\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight}{}{}
\makeatother

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

\section{One One}
\lipsum[2]

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

\lipsum[3-5]

\restoregeometry
\lipsum[6]

\end{document}


Here is a suggestion using scrlayer to define a new pagestyle for these rotated pages.

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

\usepackage{scrlayer}
\DeclareNewLayer[
background,
rightmargin,
contents={%
\parbox[b][\layerheight][c]{\dimexpr\footskip+\footheight\relax}{%
\hfill\rotatebox{90}{\pagemark}}}
]{lscape.foot}
\DeclareNewLayer[
background,
textarea,
addhoffset=\dimexpr-\headsep-\headheight\relax,
width=\dimexpr\headsep+\headheight\relax,
contents={\hfill\rotatebox{90}{\headmark}\hspace*{\headsep}}
]{lscape.head}
\DeclareNewPageStyleByLayers{lscape}{lscape.foot,lscape.head}

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

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

\restoregeometry
\lipsum[6]
\end{document}