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

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?

Solutions Collecting From Web of "How to reset footnote numbering at \chapter* and at frontmatter chapters?"

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

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.

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