I'm using the standard book class. If I write
\documentclass{book}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{foo}
\section{Donald}
\backmatter
\chapter{bar}
\section{Mickey}
\end{document}
I expect to have chapter bar numbered as appendix A and section Mickey as A.1. Instead chapter bar is not numbered and section Mickey is 1.2, following section Donald. If I insert the appendix command to obtain
\documentclass{book}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{foo}
\section{Donald}
\backmatter
\appendix
\chapter{bar}
\section{Mickey}
\end{document}
then chapter bar is unnumbered and section Mickey is numbered as .1.
What am I doing wrong?