Change position of page number after frontmatter

My grad school has very specific ideas about the placement of page numbers:

1. Preliminary pages: lowercase Roman numerals, centered 1/2 inch from the bottom of the page. Begin with the number (ii) on the first page of abstract (no pagination on title page).

2. Text: Arabic numerals, upper right-hand corner, exactly 1 inch from the right-hand edge of the page and 1/2 inch from the top. Begin with the number one (1) on the first page of text and number consecutively.

How can I achieve this using the book class, and maybe fancyhdr and the like?

Related, but for memoir: How can I change the position of my page number ONLY for one section?

EDIT: The grad school want this one-sided, apparently.

• Should you have other things in headers and footers? – Bernard Sep 26 '18 at 21:21
• Are you using one-side printing? If not, how should be even-numbered pages deat with? What are the margins for the text supposed to be? In principle, the geometry package permits customization of all the page layout parameters, including the position on the page of header and footer. – GuM Sep 26 '18 at 21:28
• No other headers and footers, and I use double-sided printing (I guess the layout should be mirrored on even pages). – user32849 Sep 26 '18 at 21:35

You can do this with geometry, but it will be nearly as complicated. I created a new pagestyle to center the page numbers relative to the page, not the text area. Using symmetrical margins would greatly simplify matters.

The tricky bit is that \topmargin, \oddsidemargin and \evensidemargin are all 1in smaller than the actual margins.

\documentclass{book}
\usepackage{lipsum}% MWE only

\pdfpageheight=\paperheight% geometry usually takes care of this
\pdfpagewidth=\paperwidth

\topmargin=-0.5in % 0.5in-1in
% use default \headsep and \footskip
% use default \oddsidemargin
\textwidth=\dimexpr \paperwidth-2in-\oddsidemargin\relax
\evensidemargin=0pt
\marginparwidth=\dimexpr 1in-2\marginparsep\relax% probably no \marginpars allowed

\makeatletter
\def\ps@frontmatter{%
\def\@oddfoot{\normalfont\hfil\thepage\hspace{\oddsidemargin}\hfil}%
\def\@evenfoot{\normalfont\hfil\hspace{\oddsidemargin}\thepage\hfil}}
\makeatother

\begin{document}
\frontmatter
\pagestyle{frontmatter}
\marginpar{This is a long line, but not nearly as long as lipsum.}
\lipsum[1-12]

\mainmatter
\chapter{Test}
\lipsum[1-8]
\end{document}


A suggestion with titleps: add

\geometry{footskip=0.5in}


in your preamble if you mean the page number should be 1/2 in below the bottom of the text area.

\frontmatter
\pagestyle{plain}
\begin{abstract}\thispagestyle{empty}
............
\end{abstract}


in the text body of the document should do it for the centred roman numbering.

For the main text, use this in your preamble:

\usepackage{titleps}
\newpagestyle{main}{%
}


For the exact placement (1 in from the right-hand edge of page on odd pages, and 1 in from the left-hand edge of page on even pages and 1/2 in fro the top), the calculations depend on the page geometry specifications from your grad school, which we don't know (yet?). Anyway, it would use, again, the geometry package.

and in the text body,

\pagestyle{main}
\mainmatter
.............

• \footskip is the distance from the bottom of the text area to the baseline of footer (for most document classes). Worse, geometry uses top and bottom to set the text area. – John Kormylo Sep 27 '18 at 0:20
• @JohnKormylo: I know that, the problem is the specifications of the O.P. are unclear: not sure whether he/she meas the top/bottom of the text area or of the physical sheet of paper. – Bernard Sep 27 '18 at 9:03
• @Bernard: The paper edge, I presume. When using \pagestyle{main}, I get ! TeX capacity exceeded, sorry [input stack size=5000]. \reserved@a ->\def \reserved@a *{\ttl@pretitlemark \z@ }\reserved@a – user32849 Sep 27 '18 at 9:45
• @user32849. Could you post a minimal complete example reproducing the problem? – Bernard Sep 27 '18 at 9:49
• I tried to reproduce the error with a MWE, but failed. It turns out this has something to do with cleveref and where I put the section labels. – user32849 Sep 27 '18 at 11:42

Here is another suggestion using package scrlayer:

\documentclass{book}
\usepackage{mwe}% MWE only

\usepackage{scrlayer}
\makeatletter
\DeclareNewLayer[
foot,
foreground,
align=b,
voffset=\paperheight-.5in,
contents=\if@mainmatter\else\vfill\hfill\thepage\hfill\fi
]{foot}
\DeclareNewLayer[
oddpage,
background,
align=tr,
voffset=.5in,
hoffset=\paperwidth-1in,
contents=\if@mainmatter\hfill\thepage\fi
\DeclareNewLayer[
evenpage,
align=l,
voffset=.5in,
hoffset=1in,
contents=\if@mainmatter\thepage\fi