# \backmatter not working

I am using the commands \frontmatter, \mainmatter and \backmatter to distinguish between the different parts of the thesis.

The first two works fine, the \backmatter doesn't: the pages numeration doesn't change from the \mainmatter to the \backmatter (I would expect to move from the usual numeration 1,2,3,4... to this one: i,ii,iii,iv...)

This is the code:

\backmatter

\cleardoublepage
\begin{thebibliography}{31}


The document class is "book":

\documentclass[12pt,a4paper]{book}


How can I get the same numbering in the \frontmatter and in the \backmatter

• What is it used for then? – Rhei Feb 6 '15 at 13:30

In the book document class, the macros \frontmatter, \mainmatter, and \backmatter are defined as follows (cf the file book.cls):

\newcommand\frontmatter{%
\cleardoublepage
\@mainmatterfalse
\pagenumbering{roman}}
\newcommand\mainmatter{%
\cleardoublepage
\@mainmattertrue
\pagenumbering{arabic}}
\newcommand\backmatter{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\@mainmatterfalse}


Observe that no change in the way pages are numbered is undertaken if \backmatter is executed. Separately, note that \@mainmatter, a Boolean switch, is set to "true" if \mainmatter is executed and is set to "false" if either \frontmatter or \backmatter is executed. (Incidentally, this Boolean switch is set initially to "true". Thus, if your document does not contain any \front/main/back-matter macros, the Boolean will be "true" for the entire document.)

So, what might be the purpose of executing \backmatter -- other than having a semantic way of creating a pagebreak and forcing all accumulated floats to be typeset? For that, it's necessary to consider what the Boolean macro \@mainmatter[true/false] does. Still consulting the file book.cls, one finds that \if@mainmatter occurs, among other places, in the definition of the macro \@chapter. Here's an excerpt from the definition of this macro:

\def\@chapter[#1]#2{%
...
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\else
\fi
...}


If \@mainmatter is "true" -- which, as we saw before, is the case in the \mainmatter portion of the document -- the chapter counter is incremented, a line of the form "Chapter n" is printed, and the chapter number and (potentially the short form of) the chapter title are written to the Table-of-Contents (toc) file. (The information written to the toc file is used when the \tableofcontents macro is executed.) Conversely, if \@mainmatter is "false" -- will be the case in the \frontmatter and \backmatter portions of the document -- just the chapter header (but no number, since the chapter counter isn't being incremented) is written to the toc file.

Traditionally, an index is in the backmatter portion of a book. Traditionally, an index is assigned a chapter-level header but no chapter number. It is for material such as indexes that the \backmatter macro should be used. (Naturally, if your book does have an index and you do want the index chapter to be numbered, don't execute the \backmatter macro.)

Let's put all this into a little MWE that contains one \chapter instruction in each of the front-, main-, and backmatter portions of the document. This is how the resulting Table of Contents looks like -- note the absence of chapter numbers for chapters "Front" and "Back", the roman page numeral for chapter "Front", and the arabic numerals for "Main" and "Back".

\documentclass{book}
\begin{document}
\frontmatter
\tableofcontents
\chapter{Front}
\mainmatter
\chapter{Main}
\backmatter
\chapter{Back}
\end{document}


The \backmatter command has the effect of changing numbered chapters to unnumbered ones, but not to change the page numbering format.

If you want roman page numbering in the backmatter, add the following lines in your preamble:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\backmatter}
{\@mainmatterfalse}
{\@mainmatterfalse\pagenumbering{roman}}
{}
{}
\makeatother


MWE:

\documentclass{book}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\backmatter}
{\@mainmatterfalse}
{\@mainmatterfalse\pagenumbering{roman}}
{}
{}
\makeatother

\usepackage{lipsum} % just for dummy text

\begin{document}

\frontmatter
\chapter{Front}
\lipsum[1]

\mainmatter
\chapter{Main}
\lipsum[1]

\backmatter
\chapter{Back}
\lipsum[1]

\end{document}


Output (backmatter)

The purpose of \backmatter is not to change page numbering, which would make very little sense (understatement for “meaningless”).

After \backmatter, chapters are not numbered any more, but they automatically go in the table of contents when specified with \chapter{title}.

Some instututions, that have very little respect for typography and common sense, require that in theses the numbering in the back matter is with Roman numerals, starting where it was left at the beginning of \mainmatter.

If you are subject to such an institution, you deserve all my sympathy. You can achieve this by modifying the definitions of \mainmatter and \backmatter.

But, please, don't do it unless you are forced to under threat on your life/degree.

\makeatletter
\newcounter{savepagenumber}
\renewcommand\mainmatter{%
\cleardoublepage
\setcounter{savepagenumber}{\value{page}}
\@mainmattertrue
\pagenumbering{arabic}%
}
\renewcommand\backmatter{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\pagenumbering{roman}%
\setcounter{page}{\value{savepagenumber}}%
\@mainmatterfalse
}
\makeatother


Complete example

\documentclass{book}

\usepackage{kantlipsum}

\makeatletter
\newcounter{savepagenumber}
\renewcommand\mainmatter{%
\cleardoublepage
\setcounter{savepagenumber}{\value{page}}
\@mainmattertrue
\pagenumbering{arabic}%
}
\renewcommand\backmatter{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\pagenumbering{roman}%
\setcounter{page}{\value{savepagenumber}}%
\@mainmatterfalse
}
\makeatother

\begin{document}

\frontmatter
\tableofcontents

\chapter{Introduction}

\kant

\mainmatter

\chapter{First}

\kant

\chapter{Second}

\kant

\backmatter

\chapter{Epilogue}

\kant

\end{document}


The front matter ends at page vi (empty) and “Epilogue” will start at page vii.