5

I'm writing two-sided using memoir. I have modified a template to put content from the front matter only on right-hand (recto) pages. This, however, does not ensure that verso pages are completely blank - they continue to show the header (chapter/section info), headrule, and footer (page number). I turned off the verso header and footer easily enough by using a separate pagestyle for the front matter. This allows me to turn those items back on in the main matter.

Can anyone help me with doing the same for the headrule please? I want it on right-hand pages only in the front matter, but on all pages in the mainmatter*. MWE below, pages ii and iv have a headrule - how do I remove it from those pages only? The headrule should be returned to both pages after the front matter.

edit: my actual front matter includes multipage table of contents and list of figures. Like the rest of the front matter, the verso pages in these sections should also be blank, while the recto pages include the headrule.

'* except for the first page of a part or chapter, although the default behaviour already hides the headrule, so that's working.

\documentclass[a4paper,11pt]{memoir}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Only print on odd pages, taken from:
% http://tex.stackexchange.com/questions/118170/table-of-content-only-on-right-side-pages
\usepackage{everyshi}
\makeatletter
\EveryShipout{\if@mainmatter\else\ifodd\c@page\null\pagebreak\fi\fi}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Set up a page style with no header or footer (page number) on left pages
% Not sure how to get left/right control of the header rule?
\makepagestyle{rightpagestyle} 
\makeoddfoot{rightpagestyle}{}{\thepage}{} 
\makeheadrule{rightpagestyle}{\textwidth}{\normalrulethickness} 
\makeoddhead{rightpagestyle}{}{}{\small\textsc{\rightmark}}
\pagestyle{rightpagestyle}


\begin{document}
\frontmatter
\chapter{This is a chapter}
First page text.
\newpage
Second page text.
\end{document}

Output

  • I would just say \thispagestyle{plain} or \thispagestyle{empty} on the two affected pages. – cfr Aug 7 '15 at 22:14
  • Thank you, I think I have made my example too minimal though! I have several different sections in my front matter and I don't know how to put those sorts of commands in the right places. One of my sections is a multi (4+) page table of contents, and all of the verso pages have this unwanted headrule - how can I get rid of it in those cases? – Cog77 Aug 7 '15 at 22:17
  • Don't you think it will look a bit weird to have it on only the right of a double-page spread? I assumed this was for empty or almost-empty pages (e.g. the copyright page or whatever). Seems to me odd to set it out this way generally. – cfr Aug 7 '15 at 22:22
  • It's a thesis. One-sided front matter is a requirement. I agree with you though. – Cog77 Aug 7 '15 at 22:23
  • So you don't actually have the contents on each side? The verso pages are all blank? (But they 'count' in terms of page numbers?) – cfr Aug 7 '15 at 22:40
5

When you make the page style for the front matter, don't worry about the verso pages. They are easier dealt with separately. Completely blank pages are much easier than what you seemed initially to be asking for ;).

I'm assuming you want at least two different heading page styles: one for the front matter and one for the main matter. If they don't need to be different, you can simplify the code that bit more.

So, to set up the two styles, use something like this:

\makepagestyle{frontps}
\makeoddfoot{frontps}{front odd left foot}{\thepage}{front odd right foot}
\makeevenfoot{frontps}{front even left foot}{\thepage}{front even right foot}
\makeoddhead{frontps}{front odd left head}{front odd centre head}{front odd right head}
\makeevenhead{frontps}{front even left head}{front even centre head}{front even right head}
\makeheadrule{frontps}{\textwidth}{\normalrulethickness}
\pagestyle{frontps}
\makepagestyle{mainps}
\makeoddfoot{mainps}{main odd left foot}{\thepage}{main odd right foot}
\makeevenfoot{mainps}{main even left foot}{\thepage}{main even right foot}
\makeoddhead{mainps}{main odd left head}{main odd centre head}{main odd right head}
\makeevenhead{mainps}{main even left head}{main even centre head}{main even right head}
\makeheadrule{mainps}{\textwidth}{\normalrulethickness}

Notice that I've deliberately specified headers and footers for both verso and recto pages for both frontps and mainps. In reality, it doesn't matter what I use for the headers and footers on verso pages in the front matter because we are going to make sure they are never displayed.

The line

\EveryShipout{\if@mainmatter\else\ifodd\c@page\null\pagebreak\fi\fi}

basically says, every time a page is shipped out, check whether it is in the main matter. If it is, carry on. If not, then do some special stuff. The special stuff says if the page is odd, then put nothing on it and start a new page.

So, all we need to do is to change this to '... then put nothing on it, clear the page headers and footers for this page, and start a new page'. That is, we just want to add \thispagestyle{empty}:

\EveryShipout{\if@mainmatter\else\ifodd\c@page\thispagestyle{empty}\null\pagebreak\fi\fi}

And that's enough.

page layouts for front and main matter

\documentclass[a4paper,11pt]{memoir}
% Only print on odd pages, taken from:
% http://tex.stackexchange.com/questions/118170/table-of-content-only-on-right-side-pages
\usepackage{everyshi,kantlipsum}
\makeatletter
\EveryShipout{\if@mainmatter\else\ifodd\c@page\thispagestyle{empty}\null\pagebreak\fi\fi}
\makeatother

\makepagestyle{frontps}
\makeoddfoot{frontps}{front odd left foot}{\thepage}{front odd right foot}
\makeevenfoot{frontps}{front even left foot}{\thepage}{front even right foot}
\makeoddhead{frontps}{front odd left head}{front odd centre head}{front odd right head}
\makeevenhead{frontps}{front even left head}{front even centre head}{front even right head}
\makeheadrule{frontps}{\textwidth}{\normalrulethickness}
\pagestyle{frontps}
\makepagestyle{mainps}
\makeoddfoot{mainps}{main odd left foot}{\thepage}{main odd right foot}
\makeevenfoot{mainps}{main even left foot}{\thepage}{main even right foot}
\makeoddhead{mainps}{main odd left head}{main odd centre head}{main odd right head}
\makeevenhead{mainps}{main even left head}{main even centre head}{main even right head}
\makeheadrule{mainps}{\textwidth}{\normalrulethickness}


\begin{document}
\frontmatter
\tableofcontents
\kant[1-5]
\mainmatter\pagestyle{frontps}
\chapter{This is a chapter}
First page text.
\newpage
Second page text.
\kant[6-20]
\end{document}
  • That works - thank you so much! Clearly, I need to actually have a go at understanding some of the commands I take from the internet... On that note, also thanks for the explanation of the \EveryShipout line from my MWE - seems obvious now but I didn't know how it worked before. – Cog77 Aug 7 '15 at 23:17
  • @Cog77 You're welcome! This was definitely what is known as an 'XY problem' ;). – cfr Aug 7 '15 at 23:22

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.