0

This question already has an answer here:

There is a portrait document in which only the second page have to be made landscape (the document has header and footer made with fancyhdr). To accomplish the portrait to landscape turn I'm using the following:

\pdfpageheight=\paperwidth
\pdfpagewidth=\paperheight
\paperwidth=\pdfpagewidth
\paperheight=\pdfpageheight 

Also, I'm using geometry to adjust layout in both modes (portrait and landscape). I'm going fine in maintaining the top and left margins across the modes. But I'm not seeing how to manage right and bottom.

To exemplify: I've tried \geometry{bottom=5cm} but in the landscape mode the footer goes beyond the page. It seems that the 4 lines of code above just cut the paper accordingly but foot stays in the same position (as in portrait mode).

What's the proper way to switch from portrait to landscape maintaining margins?

The following demonstrates what happens, foot disappear in landscape.

\documentclass[10pt,a4paper]{article}
\usepackage[left=3cm, top=5cm, headheight=2cm, height=20cm]{geometry}
\usepackage{lipsum}
\usepackage{fancyhdr}

\renewcommand{\footrulewidth}{0.4pt}

\begin{document}

\thispagestyle{fancy}
\pagestyle{fancy}

\lipsum[1]

\newpage

\pdfpageheight=\paperwidth
\pdfpagewidth=\paperheight
\paperwidth=\pdfpagewidth
\paperheight=\pdfpageheight 

\newgeometry{left=3cm, top=5cm, headheight=2cm}

\fancyhfoffset[L]{0pt}

\lipsum[1]

\restoregeometry

\paperwidth=\pdfpageheight
\paperheight=\pdfpagewidth
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth

\lipsum[1]

\end{document}

marked as duplicate by cfr, Martin Schröder, ChrisS, Paul Gaborit, egreg Jun 29 '15 at 7:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Hi, you are right, this pretty much just cuts the page. You are most likely looking for \newgeometry and \restoregeometry. – Johannes_B Jun 27 '15 at 20:20
  • Yes, I'm already doing \newgeometry just after the 4 lines of code shown earlier and then \restoregeometry at the end of the page. The issue is that I'm missing the criteria to maintain the foot at the same (relative to bottom) position in landscape. – oqrxke Jun 27 '15 at 20:25
  • I've read a little bit about koma-script, should it make this easier to deal with? – oqrxke Jun 27 '15 at 20:29
  • Not sure what exactly you are after, maybe the following contains something usefule How to translate and rotate the heading of landscaped pages?; btw: with newgeometry, you should not use the pdf-primitives. geometry will take care of setting everything right. – Johannes_B Jun 27 '15 at 20:35
  • \pdflscale rotates header and footer (they appear horizontally in landscape). – oqrxke Jun 27 '15 at 20:52
2

If you use pdflscape then, in a landscape environment, the headers and footers remain untouched. Only the content of the page uses the new orientation, and, if your PDF viewer respects the instruction, the relevant page will be automatically rotated for your viewing pleasure.

For example:

\documentclass{article}
\usepackage{pdflscape,kantlipsum}
\pagestyle{headings}
\begin{document}

  \title{Title}
  \author{Author}
  \section{A section}
  \kant[1]
  \begin{landscape}
    \kant[2]
  \end{landscape}
  \kant[3]

\end{document}

pdflscape

If you use lscape, then the page is treated in the same way as with pdflscape but the viewer is not asked to automatically rotate pages.

\documentclass{article}
\usepackage{pdflscape,kantlipsum}
\pagestyle{headings}
\begin{document}

  \title{Title}
  \author{Author}
  \section{A section}
  \kant[1]
  \begin{landscape}
    \kant[2]
  \end{landscape}
  \kant[3]

\end{document}

lscape

In neither case are the headers or footers rotated or the margins of the pages altered for landscaped pages.

  • Trying to clarify... I need header and footer aligned with the contents in landscape also. The behavior of of \pdflscape and \lscape isn't desired. – oqrxke Jun 27 '15 at 23:35
  • Just edited the question, updated the sample code which shows the thing: The landscape page is missing the foot (it is beyond the page). I guess height should be added in the \newgeometry{left=3cm, top=5cm, headheight=2cm, height=Xcm} to make it appear. Question is: How to compute X so that distance of the foot from the bottom is the same as in normal (portrait) pages? – oqrxke Jun 27 '15 at 23:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.