0

This question came from a derivation of How to translate and rotate the heading of landscaped pages?

I want to rotate the header (with have page number and chapter name) on some landscape pages that are not sequential.

I am using the code proposed by 沙漠之子 user that works very well not generating conflicts with the other packages that I use. The problem is that this solution appear to be single shot, after \restoregeometry command I can make work the \newgeometry{,hmargin=3cm,vmargin=5cm,landscape} again.

My intention is use as:

\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=2cm]{geometry} % Margins.
    \makeatletter
    \def\ifGm@preamble#1{\@firstofone}
    \appto\restoregeometry{%
        \pdfpagewidth=\paperwidth
        \pdfpageheight=\paperheight}
    \apptocmd\newgeometry{%
        \pdfpagewidth=\paperwidth
        \pdfpageheight=\paperheight}{}{}
    \makeatother
\newcommand{\newgeometrylandscape}{\newgeometry{top=3cm,bottom=2cm,left=3cm,right=2cm,landscape}}

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

\section{One One}
\lipsum[2]

\newgeometry{hmargin=3cm,vmargin=5cm,landscape}
Landscape part 1
\lipsum[3-5]
\restoregeometry

\lipsum[6]


\newgeometry{hmargin=3cm,vmargin=5cm,landscape}
Landscape part 2
\lipsum[3-5]
\restoregeometry

\end{document}
hildogjr
  • 103

1 Answers1

0

The workaround that I create is change the \newgeometry to force the value of variables that wasn't changed at the second time that the macro was called.

    \apptocmd\newgeometry{%
        \paperwidth=297mm
        \paperheight=210mm
        \textwidth=702.78308pt
        \linewidth=\textwidth
        \hsize=\textwidth
        \columnwidth=\textwidth
        \pdfpagewidth=\paperwidth
        \pdfpageheight=\paperheight
        }{}{}
hildogjr
  • 103