The \appendix command resets the section counter to zero:
*\documentclass{article}
*\show\appendix
(/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo))
> \appendix=\long macro:
->\par \setcounter {section}{0}\setcounter {subsection}{0}\gdef \thesection {\@
Alph \c@section }.
My understanding of \section is that it creates a bookmark based on the current counter number? In the following, I feel that I reproduce the critical parts of what \appendix does before declaring \section{six}, but it does not work.
\documentclass{article}
\usepackage[final]{hyperref}
\begin{document}
\tableofcontents
\newpage
\section{one}
\newpage
\section{two}
\newpage
\section{three}
\newpage
\appendix
\section{four}
\newpage
\section{five}
\setcounter{section}{0}
\setcounter{subsection}{0}
\section{six}
\end{document}
Instead, \section{six} has a bookmark which leads to \section{four}. The output of LaTeX understandably shows:
pdfTeX warning (ext4): destination with the same identifier
(name{appendix.A}) has been already used, duplicate ignored
So I don't understand why this is happening. Does \appendix do more than what I think it is doing? The redefinition \thesection does not seem relevant here.