Page LayoutMemoir - Footer on 1st page of Chapter (with MWE!)

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Memoir - Footer on 1st page of Chapter (with MWE!)

Post by Julian_S_Moore »

First, very many thanks for to the various people who have helped me plod forward... I nearly have what I need in terms of layout (then it will be on to underfull/overfull boxes, widow/orphan control etc.) but there are two lingering problems...

1. I now have the various elements I want in headers and footers (chapter title in header, unique per page graphics in the footer etc.) but on the 1st page of a chapter the (even) footer is just the plain footer and not what I have specified. Obviously (?) I wouldn't want a chapter title header on the 1st page so Memoir is doing the sensible thing by suppressing it, but I do not get the footer I have specified.

I have overcome this by creating a special "1st page" style and forcing it using \thispagestyle... Is there a better way to do this?

2. Calling \chapter, which calls \cleardoublepage, results in a blank verso page thanks to a call (somewhere) of \thispagestyle{cleared}. How would I override that so that I still have header and/or footer on the blank verson? (or otherwise achieve the desired result?)

In this instance there is a minimal working example (font set to Times New Roman for the convenience of others...)

Code: Select all

\documentclass[final,twoside,openright,showtrims,10pt]{memoir} %

% XeTeX stuff
\usepackage{xltxtra,fontspec,xunicode}

% Page styles
\makepagestyle{fragPage}
\makeheadrule{fragPage}{\textwidth}{0.5pt} % for testing only
\makefootrule{fragPage}{\textwidth}{0.5pt}{0pt} % NOTE THE EXTRA footskip parameter % for testing only
\makeevenhead{fragPage}{}{\fontsize{11.5}{13.8} \fontspec[FakeSlant=0.3]{Times New Roman}\leftmark}{}
\makeoddhead{fragPage}{}{\fontsize{11.5}{13.8} \fontspec[FakeSlant=0.3]{Times New Roman}\rightmark}{}
% for the footers, the right way to get the unique per page graphic is to use "Ch\thechapter{}P\thesheetsequence{}.eps"
\makeevenfoot{fragPage}{Ch\thechapter{}P\thesheetsequence{}.eps}{graphic code here}{\thepage}
\makeoddfoot{fragPage}{\thepage}{graphic code here}{Ch\thechapter{}P\thesheetsequence{}.eps}
\makeatletter % GENERALLY required in case of \@chapapp usage in \makepsmarks
	\makepsmarks{fragPage}{
	\nouppercaseheads % I don't like the uppercase heads
	\createmark{chapter}{both}{nonumber}{}{}
}
\makeatother % RETURN @ to being a non-letter

\makepagestyle{fragFirstChPage}
\makefootrule{fragFirstChPage}{\textwidth}{0.5pt}{0pt} % NOTE THE EXTRA footskip parameter % for testing only
\makeevenhead{fragFirstChPage}{}{}{}
\makeoddhead{fragFirstChPage}{}{}{}
% for the footers, the right way to get the unique per page graphic is to use "Ch\thechapter{}P\thesheetsequence{}.eps"
\makeoddfoot{fragFirstChPage}{Ch\thechapter{}P\thesheetsequence{}.eps}{graphic code here}{\thepage}
\makeevenfoot{fragFirstChPage}{}{}{}
%\makeatletter % GENERALLY required in case of \@chapapp usage in \makepsmarks
%	\makepsmarks{fragFirstChPage}{
%	\nouppercaseheads % I don't like the uppercase heads
%	\createmark{chapter}{both}{}{}{}
%}
%\makeatother % RETURN @ to being a non-letter

\makechapterstyle{fragChap}{% Param 1 is the name of the chapter style to be made, and #2 is the code...
  \setlength{\beforechapskip}{-1\headsep}
  \setlength{\midchapskip}{0pt}
  \setlength{\afterchapskip}{24pt}
	\renewcommand*{\printchaptername}{}
	\renewcommand*{\printchapternum}{}
	\renewcommand*{\printchapternonum}{}
	\renewcommand*{\afterchapternum}{}
	\renewcommand*{\chaptitlefont}{\fontsize{44}{44} \fontspec{Times New Roman}}
	\renewcommand*{\printchaptertitle}[1]{\centering\chaptitlefont ##1}
}

\begin{document}
\pagestyle{fragPage}
\chapterstyle{fragChap}
\chapter{This IS The 1st Title}
\thispagestyle{fragFirstChPage}
Chapter 1... Page 1 - blah blah blah\par \vfill
\pagebreak[4]
Chapter 1... Page 2 - blah blah blah\par \vfill
\pagebreak[4]
Chapter 1... Page 3 - blah blah blah\par \vfill

\chapter{This IS The 2nd Title}
[Without a special thispagestyle...]
Chapter 2... Page 1 - blah blah blah\par \vfill
\pagebreak[4]
Chapter 2... Page 2 - blah blah blah\par \vfill
\pagebreak[4]
Chapter 2... Page 3 - blah blah blah\par \vfill

\end{document}
Thanks

PS I've discovered that e.g. \pagestyle{style} has to come before \chapter... how does one know (infer from first principles?) that this is the required order? If I put the \pagestyle after \chapter then the headers and footers are whatever the default is... when does a \pagestyle command take effect?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Memoir - Footer on 1st page of Chapter (with MWE!)

Post by meho_r »

I've already answered your question here. The same principle goes for an empty verso page before a new chapter: simply use \aliaspagestyle and assign a custom page style to cleared page style as you do for chapter page style. No need for \thispagestyle. Here's your code with a slight addition and few modifications (added 2 lines just before \begin{document}, put \pagestyle{fragPage} in the Preamble after those 2 lines and commented page style related stuff in the document):

Code: Select all

\documentclass[final,twoside,openright,showtrims,10pt]{memoir} %

% XeTeX stuff
\usepackage{xltxtra,fontspec,xunicode}

% Page styles
\makepagestyle{fragPage}
\makeheadrule{fragPage}{\textwidth}{0.5pt} % for testing only
\makefootrule{fragPage}{\textwidth}{0.5pt}{0pt} % NOTE THE EXTRA footskip parameter % for testing only
\makeevenhead{fragPage}{}{\fontsize{11.5}{13.8} \fontspec[FakeSlant=0.3]{Times New Roman}\leftmark}{}
\makeoddhead{fragPage}{}{\fontsize{11.5}{13.8} \fontspec[FakeSlant=0.3]{Times New Roman}\rightmark}{}
% for the footers, the right way to get the unique per page graphic is to use "Ch\thechapter{}P\thesheetsequence{}.eps"
\makeevenfoot{fragPage}{Ch\thechapter{}P\thesheetsequence{}.eps}{graphic code here}{\thepage}
\makeoddfoot{fragPage}{\thepage}{graphic code here}{Ch\thechapter{}P\thesheetsequence{}.eps}
\makeatletter % GENERALLY required in case of \@chapapp usage in \makepsmarks
   \makepsmarks{fragPage}{
   \nouppercaseheads % I don't like the uppercase heads
   \createmark{chapter}{both}{nonumber}{}{}
}
\makeatother % RETURN @ to being a non-letter

\makepagestyle{fragFirstChPage}
\makefootrule{fragFirstChPage}{\textwidth}{0.5pt}{0pt} % NOTE THE EXTRA footskip parameter % for testing only
\makeevenhead{fragFirstChPage}{}{}{}
\makeoddhead{fragFirstChPage}{}{}{}
% for the footers, the right way to get the unique per page graphic is to use "Ch\thechapter{}P\thesheetsequence{}.eps"
\makeoddfoot{fragFirstChPage}{Ch\thechapter{}P\thesheetsequence{}.eps}{graphic code here}{\thepage}
\makeevenfoot{fragFirstChPage}{}{}{}
%\makeatletter % GENERALLY required in case of \@chapapp usage in \makepsmarks
%   \makepsmarks{fragFirstChPage}{
%   \nouppercaseheads % I don't like the uppercase heads
%   \createmark{chapter}{both}{}{}{}
%}
%\makeatother % RETURN @ to being a non-letter

\makechapterstyle{fragChap}{% Param 1 is the name of the chapter style to be made, and #2 is the code...
  \setlength{\beforechapskip}{-1\headsep}
  \setlength{\midchapskip}{0pt}
  \setlength{\afterchapskip}{24pt}
   \renewcommand*{\printchaptername}{}
   \renewcommand*{\printchapternum}{}
   \renewcommand*{\printchapternonum}{}
   \renewcommand*{\afterchapternum}{}
   \renewcommand*{\chaptitlefont}{\fontsize{44}{44} \fontspec{Times New Roman}}
   \renewcommand*{\printchaptertitle}[1]{\centering\chaptitlefont ##1}
}


\aliaspagestyle{chapter}{fragFirstChPage}
\aliaspagestyle{cleared}{fragPage}

\pagestyle{fragPage}

\begin{document}
%\pagestyle{fragPage}% Put in Preamble

%\chapterstyle{fragChap}% No need for this; aliaspagestyle solve it
%EDIT: Actually, it has nothing to do with page style, 
%so uncomment it

\chapter{This IS The 1st Title}
%\thispagestyle{fragFirstChPage}
Chapter 1... Page 1 - blah blah blah\par \vfill
\pagebreak[4]
Chapter 1... Page 2 - blah blah blah\par \vfill
\pagebreak[4]
Chapter 1... Page 3 - blah blah blah\par \vfill

\chapter{This IS The 2nd Title}
[Without a special thispagestyle...]
Chapter 2... Page 1 - blah blah blah\par \vfill
\pagebreak[4]
Chapter 2... Page 2 - blah blah blah\par \vfill
\pagebreak[4]
Chapter 2... Page 3 - blah blah blah\par \vfill

\end{document}
P.S. \pagestyle takes effect at the very same page it is put on. If you put it after \chapter command on the first page of a chapter, it'll take effect on the next page since memoir has reserved chapter page style for the first page of a chapter. No difference if you put it before \chapter command: you'll still have chapter page style applied to the first page of a chapter.
Last edited by meho_r on Tue Nov 17, 2009 10:36 pm, edited 2 times in total.
Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Memoir - Footer on 1st page of Chapter (with MWE!)

Post by Julian_S_Moore »

Thanks - yes you did reply to another question... but now I understand the answer better.

I'm looking at the code mods (the output isn't quite the same as my MWE output... (how did "Chapter 1" sneak back in on p1?) but I expect the difference will be quickly apparent.

Observations: I didn't know that there was a "cleared" page style... I assumed it was just a cleared page. And of course I didn't know there was a pagestyle called "chapter" and that I could restyle the chapter by redefining it.

I'm going away to digest your contribution now...

Very useful; thank you.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Memoir - Footer on 1st page of Chapter (with MWE!)

Post by meho_r »

Sorry, my mistake, uncomment \chapterstyle{fragChap}, just after \begin{document}, it has nothing to do with page style formatting. I put a note in the code above.
Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Re: Memoir - Footer on 1st page of Chapter (with MWE!)

Post by Julian_S_Moore »

No worries :) I think even I would have spotted it fairly quickly, but it's even nicer to have it pointed out.

I am slowly getting the hang of this stuff...
Post Reply