0

@Leo Liu's geometry patch seemed too good to be true, and as it turns out it works only once (in this case, for chapter Bar, not Qux). It there a modidification that would make it always work? Side issue: why doesn't pagestyle have any effect?

\documentclass{report}
\usepackage[a6paper]{geometry}
\usepackage{lscape,lipsum}
\usepackage{etoolbox}
\usepackage{xparse}

%https://tex.stackexchange.com/a/374533/112708%--------------
\makeatletter
\def\ifGm@preamble#1{\@firstofone}
\appto\restoregeometry{%
  \pdfpagewidth=\paperwidth
  \pdfpageheight=\paperheight}
\apptocmd\newgeometry{%
  \pdfpagewidth=\paperwidth
  \pdfpageheight=\paperheight}{}{}
\makeatother

\usepackage{titleps}%-----------------------------------------
\usepackage{lastpage}
\newpagestyle{cust}
{
  \setfoot{%
    \thepage/\pageref{LastPage}
  }{}{}
}

\begin{document}%---------------------------------------------
%\pagestyle{empty}%Ignored
\pagestyle{cust}%Ignored
\chapter{Foo}
\lipsum[1][1]

\newgeometry{,top=2em,landscape}
\savegeometry{landscape}
\chapter{Bar}
\lipsum[1][2]


\restoregeometry
\chapter{Baz}
\lipsum[1][3]

%\newgeometry{,top=2em,landscape}%Ignored
\loadgeometry{landscape}%Ignored
\chapter{Qux}
\lipsum[1][4]

\end{document}%-----------------------------------------------

Shot 1 Shot 2

0

You need to patch \loadgeometry too. And the first page of a chapter uses plain style, so you need to change this page style.

\documentclass{report}
\usepackage[a6paper]{geometry}
\usepackage{lscape,lipsum}
\usepackage{etoolbox}
\usepackage{xparse}

%https://tex.stackexchange.com/a/374533/112708%--------------
\makeatletter
\def\ifGm@preamble#1{\@firstofone}
\appto\restoregeometry{%
  \pdfpagewidth=\paperwidth
  \pdfpageheight=\paperheight}
\apptocmd\newgeometry{%
  \pdfpagewidth=\paperwidth
  \pdfpageheight=\paperheight}{}{}
\apptocmd\loadgeometry{%
  \pdfpagewidth=\paperwidth
  \pdfpageheight=\paperheight}{}{}  
\makeatother

\usepackage{titleps}%-----------------------------------------
\usepackage{lastpage}
\newpagestyle{cust}
{
  \setfoot{%
    \thepage/\pageref{LastPage}
  }{}{}
}
\renewpagestyle{plain}
{
  \setfoot{%
    \thepage/\pageref{LastPage}
  }{}{}
}
\begin{document}%---------------------------------------------
%\pagestyle{empty}%Ignored
\pagestyle{cust}%Ignored
\chapter{Foo}
\lipsum[1][1]

\newgeometry{,top=2em,landscape}
\savegeometry{landscape}
\chapter{Bar}
\lipsum[1][2]


\restoregeometry
\chapter{Baz}
\lipsum[1][3]

%\newgeometry{,top=2em,landscape}%Ignored
\loadgeometry{landscape}%Ignored
\chapter{Qux}
\lipsum[1][4]

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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