Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a memoir document with introductory material (title page, table of contents, etc.) in the \frontmatter section. How do I prevent page numbers from automatically being put on these pages (currently they are roman numerals)? I still want normal arabic page numbers on every page in the \mainmatter section.

\documentclass{memoir}
\begin{document}

\frontmatter
\title{My Book}
\author{Me}
\maketitle

\mainmatter
Some text.

\end{document}

I am aware that I can switch page numbers on and off with \pagenumbering{gobble} and \pagenumbergin{arabic}. But I'm looking for a memoir setting which will automatically turn off page numbering for the \frontmatter section. (I'm asking because main document has lots of settings which seem to conflict with \pagenumbering{gobble} and generate warnings.)

EDIT:

As egreg pointed out, these warnings in my main document are generated by a conflict with the hyperref package.

EDIT 2:

If possible, I would like to remove the numbers from all pages in \frontmatter, but keep the page numbers in \mainmatter using my custom header and fooder settings:

% Headers and Footers

\nouppercaseheads

\makepagestyle{mystyle} 
\setlength{\headwidth}{\dimexpr\textwidth+\marginparsep+\marginparwidth\relax}
\makerunningwidth{mystyle}{\headwidth}

\makeevenhead{mystyle}{\itshape\leftmark}{}{}
\makeoddhead{mystyle}{}{}{\itshape\leftmark}
\makeevenfoot{mystyle}{\thepage}{}{}
\makeoddfoot{mystyle}{}{}{\thepage}
\makepsmarks{mystyle}{\createmark{chapter}{left}{}{}{}}

\makeatletter
\makepsmarks{mystyle}{\createmark{chapter}{left}{shownumber}{\@chapapp\ }{:\ }}
\makeatother

\makepagestyle{plain}
\makerunningwidth{plain}{\headwidth}
\makeevenfoot{plain}{\thepage}{}{}
\makeoddfoot{plain}{}{}{\thepage}

\pagestyle{mystyle}
share|improve this question

2 Answers 2

up vote 6 down vote accepted

The warnings are probably caused by hyperref, because you're not generating the page numbers that the package needs for setting anchors. It's probably better to redefine the page style for frontmatter to empty:

\documentclass{memoir}
\usepackage{hyperref,kantlipsum,etoolbox}

\makeatletter
\aliaspagestyle{title}{empty} % suppress the page number after \maketitle
\let\origps@chapter\ps@chapter
\preto\frontmatter{\let\ps@chapter\ps@empty\pagestyle{empty}}
\preto\mainmatter{%
  \cleardoublepage
  \let\ps@chapter\origps@chapter\pagestyle{headings}}
\makeatother

\begin{document}

\frontmatter
\title{My Book}
\author{Me}
\maketitle

\tableofcontents*

\chapter{Intro}
\kant

\mainmatter

\chapter{First}
\kant
\end{document}

Change headings into mystyle if you want to use this one in the main matter.


Personally I find it a bad idea to suppress page numbers: every page should have a printed number, in order to help the reader in consulting the document. Only some special pages may be an exception (dedication or colophon, for example, but not an introduction). But this depends on the document, of course; if the frontmatter consists only of a title page and a one page table of contents the page numbers are probably not necessary. If the frontmatter has table of contents, list of figures and other material such as a preface, the pages should be numbered, in my opinion.

share|improve this answer
    
Thanks for your help. In my main document, I have custom header and footer settings, and your code seems to override them (whether I put it before or after my settings). In other words, now it correctly eliminates numbers from the \frontmatter pages, but it restores the header and footer settings to the memoir default... –  jamaicanworm Apr 26 '12 at 20:59
    
@jamaicanworm How do you define them? You see, it's impossible to tell without this information. That's why I used the "generic" headings page style. –  egreg Apr 27 '12 at 17:44
    
Please see EDIT 2 in my question. Thanks! –  jamaicanworm Apr 27 '12 at 17:59
1  
@jamaicanworm Just change headings into mystyle; it's not necessary to issue \pagestyle{mystyle} in the preamble, of course, as it will be issued by \mainmatter. –  egreg Apr 27 '12 at 18:03

Memoir provides \aliaspagestyle{}{} for this purpose:

\documentclass{memoir}
\begin{document}

\frontmatter
\pagestyle{empty}
\aliaspagestyle{chapter}{empty}
\title{My Book}
\author{Me}
\maketitle

\mainmatter
% \aliaspagestyle{chapter}{ruled}
\pagestyle{ruled}% <-- for example
\chapter{A Chapter}
Some text.

\end{document}
share|improve this answer
    
There's a little problem in restoring the default chapter pagestyle. –  egreg Apr 26 '12 at 20:41
    
@egreg -- Could you elaborate on your comment? –  jon Apr 26 '12 at 20:46
1  
I tried it, and LaTeX goes into a loop when trying to restore the previous setting of the chapter page style with \aliaspagestyle. But with \let\originalps@chapter\ps@chapter one can restore it later, exchanging the two commands. –  egreg Apr 26 '12 at 20:55
2  
@egreg -- I can't reproduce it (rather, I can't create the example you're describing). But if the goal is simply to get rid of all page numbering and then start using page numbering without ever going back to no page numbers, I don't think you need to go back to a previous setting. (Also, there is \copypagestyle{<copy>}{<original>}, which would be one way to break the loop, much like \let\origcmd\cmd, etc.) –  jon Apr 26 '12 at 21:08
1  
Yes, you're right! \copypagestyle is the answer! –  egreg Apr 26 '12 at 21:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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