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.

A comment to my answer to Biblatex and citation reset between chapters made me realize that, contrary to normal chapters in the book and report class, \chapter* (the starred version) does not reset the numbering of footnotes:

\documentclass{book}

\begin{document}

\chapter*{Preface}

Some text.\footnote{A footnote}

\chapter*{Introduction}

Some text.\footnote{A footnote}

\chapter{First}

Some text.\footnote{A footnote}

\end{document}

The same is true for \chapter in the frontmatter of the book class:

\documentclass{book}

\begin{document}

\frontmatter

\chapter{Preface}

Some text.\footnote{A footnote}

\chapter{Introduction}

Some text.\footnote{A footnote}

\mainmatter

\chapter{First}

Some text.\footnote{A footnote}

\end{document}

How to reset footnote numbering at \chapter* and at frontmatter chapters?

share|improve this question
    
This would probably be easiest by patching the \chapter command. –  Stephan Lehmke Apr 27 '12 at 4:17
    
@StephanLehmke I suspected so, but I'm not familiar with patching only the starred version of a command (the non-starred version \chapter works fine). –  lockstep Apr 27 '12 at 4:18
    
But it wouldn't harm setting the footnote counter to zero twice in immediate succession, would it? –  Stephan Lehmke Apr 27 '12 at 4:21
    
@StephanLehmke Probably not, but I have been surprised by counter behaviour on another occasion: tex.stackexchange.com/questions/24822/… –  lockstep Apr 27 '12 at 4:24
    
\@makeschapterhead typesets the title of "starred" chapters. See my answer. –  Stephan Lehmke Apr 27 '12 at 4:35
show 1 more comment

3 Answers

up vote 10 down vote accepted

I would patch \@chapter and \@schapter to set the footnote counter to zero; the first one will take care of the situation for \chapter* and the second one will take care of chapters created with \chapter under \frontmatter (the chapter counter is not reset under \frontmatter since the definition for \@chapter starts with

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%

and \frontmatter does

\@mainmatterfalse

So the patching would be something like

\usepackage{etoolbox}

\makeatletter
\pretocmd{\@schapter}{\setcounter{footnote}{0}}{}{}
\pretocmd{\@chapter}{\setcounter{footnote}{0}}{}{}
\makeatother
share|improve this answer
    
Just to be sure: Patching \@chapter will reset the footnote counter twice for mainmatter chapters (by yor patch plus by \refstepcounter{chapter} -- do you think this is insignificant? –  lockstep Apr 27 '12 at 4:49
1  
I would use \pretocmd, otherwise there could be a problem with a footnote inside the chapter title. –  Stephan Lehmke Apr 27 '12 at 4:51
    
@StephanLehmke: now it's my turn: darn! ;-) –  Gonzalo Medina Apr 27 '12 at 4:52
    
@lockstep: No, I think it's not a problem. –  Gonzalo Medina Apr 27 '12 at 4:56
    
It was hard to chose among the two answers, especially because both Stefan and you improved the other one's answer. I accepted Stefan's answer beccause its latest version works for memoir (both answers work for KOMA-Script classes). –  lockstep Apr 27 '12 at 5:19
show 2 more comments

Although both answers provided so far, solved the problem with the footnote counters, perhaps a better way is to define semantic commands for the additional front matter sections.

This is a much better approach than injecting material into the posterior or anterior of macros, with yet another package.

I have seen sections in front matter as Preface, Foreword, Acknowledgments, Series Editor's Preface, About this Book, List of Contributors, Definitions, Author Affiliations, Abbreviations, Declaration and many others, and that is in English books. These sometimes are also included in the Table of Contents. Some of them are signed and others have a variety of other formatting requirements. For this reason I prefer to set them as environments.

Here is a factory command for making such environments (solving the footnote problem as well) and enforcing consistency all in five lines of code and no need for any package.

\newcommand\forewordname{foreword}
\newcommand\definitionsname{Definitions}
\newcommand\makepreamblecmd[1]{%
    \expandafter\newenvironment\expandafter{#1}{%
    \setcounter{footnote}{0}
    \chapter*{#1}}% could be other formatting macro
{}}

You create the new environments so,

 \makepreamblecmd{\forewordname}
 \makepreamblecmd{\definitionsname}

By using macros such as \forewordname you also cater for languages other than English.

Here is a full minimal,

\documentclass{book}
\makeatletter
\newcommand\forewordname{foreword}
\newcommand\definitionsname{Definitions}
\newcommand\prefacename{Preface}
\newcommand\makepreamblecmd[1]{%
    \expandafter\newenvironment\expandafter{#1}{%
    \setcounter{footnote}{0}
   \chapter*{#1}}%
{}}

\title{test}
\begin{document}
\frontmatter
\maketitle
\tableofcontents
\makepreamblecmd{\forewordname}
\makepreamblecmd{\definitionsname}
\makepreamblecmd{\prefacename}
\begin{foreword}
Some text.\footnote{A footnote}
Some text.\footnote{A footnote}
\end{foreword}
\begin{Definitions}
Some text.\footnote{A footnote}
Some text.\footnote{A footnote}
\end{Definitions}

\begin{Preface}
Some text.\footnote{A footnote}
Some text.\footnote{A footnote}
\end{Preface}

\mainmatter
\chapter{First}
Some text.\footnote{A footnote}
\end{document}

One could modify the "factory method" that generates the environments to add the name to the ToC and to ensure it is hyperlinked, if required.

share|improve this answer
add comment

As Gonzalo mentioned, it's not sufficient to only patch the macro to output the "starred" version of the chapterhead. So I suggest to patch \chapter.

\usepackage{etoolbox}

\makeatletter
\patchcmd\chapter{\thispagestyle}{\global\c@footnote\z@\thispagestyle}{}{}
\makeatother
share|improve this answer
    
+1. Is \global essential, or only a safety precaution? –  lockstep Apr 27 '12 at 4:40
2  
But this won't solve the problem for \frontmatter. –  Gonzalo Medina Apr 27 '12 at 4:44
1  
@lockstep In this case, the optional argument handling it done by \secdef which comes after my patch. Inserting after \thispagestyle{plain} is really a good place because it comes after \cleardoublepage(no issues with held over material) at a time when global ressources are configured. –  Stephan Lehmke Apr 27 '12 at 4:58
1  
Is inserting \global\c@footnote\z@ immediately before \thispagestyle safe? This way, your solution would work with the memoirclass -- its \chapter command uses \thispagestyle{chapter}. –  lockstep Apr 27 '12 at 5:09
1  
@StephanLehmke \setcounter{footnote}{0} is precisely the same as \global\c@footnote\z@. Well, it also checks if the counter is defined, which it is. I'd advocate the LaTeX method. –  egreg Apr 28 '12 at 9:13
show 7 more comments

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.