# Hyperref levels are embedded, aren't being reset

I'm using the hyperref package with a custom class, and I'm having a problem with hyperref not creating the tree correctly. What I expect to see is this:

+ Section 1
++ Section 1.1
++ Section 1.2
+++ Section 1.2.1
+++ Section 1.2.2
++ Section 1.3
+ Section 2
++ Section 2.1

But what I'm seeing instead is this:

+ Section 1
++ Section 1.1
++ Section 1.2
+++ Section 1.2.1
+++ Section 1.2.2
++++ Section 1.3
+++++ Section 2
++++++ Section 2.1

I am guessing there is some kind of level counter that keeps track of what level of section, subsection, subsubsection, etc. the tree is on, and this just isn't being reset when I run \clearpage or when I create a chapter or section header. But I don't know how to reset it, and I don't know what kind of mechanism hyperref uses to keep track of this. I've been unable to figure out how hyperref does this on my own.

How can I control hyperref's level "counter" from the Latex class level?

Any help would be greatly appreciated.

-
Off the cuff, I would imagine hyperref uses the counter secnumdepth to identify the indentation/level of the section. I'm guessing your 'custom class' has a \addtocounter{secnumdepth}{1} somewhere in the \section{...} and \subsection{...} definition. Perhaps even a conditional increment since some of the section/subsections are at the same level. –  Werner Aug 9 '11 at 21:38
@user463213: Try adding \usepackage{etoolbox} \pretocmd{\section}{\addtocounter{secnumdepth}{-1}}{}{} \pretocmd{\subsection}{\addtocounter{secnumdepth}{-1}}{}{} to your preamble to drop the secnumdepth counter by one and revert your documentclass changes. –  Werner Aug 24 '11 at 5:26