# Either page number or text body should be 1 inch from the margin depending on whether page begins a chapter

## Problem

How can I write a document class to place page numbers one inch from the bottom on pages with a chapter heading and place the text body one inch from the bottom on pages without a chapter heading (with page numbers in the header instead)?

## Details

I'm voluntarily creating a thesis class for my university so that future students don't have to worry about the formatting and layout of their theses if they choose to write them in LaTeX. The university thesis guide requires that if a page includes a chapter heading then the page number should be 1 inch from the bottom of the page but if a page does not contain a chapter heading then the page number should appear as specified by the appropriate style guide.

So far this is easily implemented by using the geometry package with the appropriate margins and the includeheadfoot option (like in this question) and then specifying an appropriate default pagestyle (since pages with chapter headings will override with plain pagestyle as desired).

The catch is that the thesis guide also requires that if a page number is not on the bottom then the text body must be 1 inch from the bottom of the paper instead. Since all the style guides (APA, MLA, Chicago/Turabian, etc.) suggest putting page numbers in the header, for me this means a page number is in the footer if and only if the page has a chapter heading.

Perhaps if I could somehow modify the geometry of pages that have chapter headings to use the includefoot option while other pages default to a geometry without that option, I could solve my problem. The accepted answer to this question about changing geometry for a single page gave me the idea to patch \chapter with \pretocmd like so:

\pretocmd{\chapter}{\newgeometry{margin=1in,includeheadfoot}}{}{}


The only issue with this approach is I don't know how to restore geometry on subsequent pages of a chapter, especially since I won't know the contents of chapters.

## MWE

\documentclass[letterpaper,12pt]{report}
\usepackage{lipsum}

% Remove includefoot option above and uncomment lines below to see patch attempt.
% \usepackage{etoolbox}

\begin{document}
\chapter{Test}
Page number on this page should be in the footer and 1in from the bottom of the page.  Page number on the next page should be in the header and 1in from the top of the page and last line of text on the next page should be 1in from the bottom of the page.\par
\lipsum[1-10]
\end{document}

• May be I am wrong but when I have tried \pretocmd{\chapter}{\newgeometry{margin=1in,includeheadfoot}}{}{} I noticed that there is no need to add anything else to restore the old geometry for subsequent pages. – Hafid Boukhoulda May 17 at 16:52
• @HafidBoukhoulda Forgive me, but I don't get this behavior? If I use the MWE as-is or if I remove the includefoot option from the \usepackage[...]{geometry} line and then uncomment the patch, all pages in the MWE behave as if includefoot is enabled. Only the page with the chapter heading should behave as if includefoot is enabled while all the remaining pages should behave as if it wasn't. – FringePioneer May 17 at 21:07

To accomplish what you described, the first step is to use the geometry package to implement a default page layout with only a header (using includehead).

The plain page style (having a footer instead of a header) could then adjust the \topmargin value for just the one page in which the chapter heading is located; in effect, moving the header with no text into the top margin while also bringing the footer above the bottom 1" margin.

To implement this approach, try the following (based on your working example):

\documentclass[letterpaper,12pt]{report}

% Define default page layout with 1" margins and header only

\usepackage{lipsum}

% Plain page style adjusted with the footer above bottom margin
\usepackage{etoolbox}
\makeatletter
\appto{\ps@plain}{%

Note: Using this approach, the geometry package's showframe option does not properly render on pages that use the plain page style.