I am writing a thesis with document class report and I am using hyperref. My structure is the following:

\chapter{First chapter}
\section{First section}
    \subsection{First sub section}
        \subsubsection*{My Section}

However, I'd like to reference the \subsubsection with their name, but I don't want to number them (at all in the whole document). For example, I could write (using \nameref command):

In Section "My Section" we saw that...

However, if I add label to that section, it references to the subsection (First sub section). This is what I have:

\addcontentsline{toc}{subsubsection}{My title}
\subsubsection*{My title}

Moving \label command between \phantomsection and \addcontentsline makes it reference to the previous subsection. How could I make it refer to the unnumbered subsubsection?

  • 1
    subsubsections aren't numbered by default (or are they in report?). Either way, if you don't want to number them throughout you can set the secnumdepth counter to 2. This will cause only parts, chapters, and sections to be numbered. It allows you to write \subsubsection instead of the starred variant. If you then later decide that you do want to number them, the change is limited to the counter instead of removing * throughout your document. You can use the nameref package to reference sections by name. – Roelof Spijker Nov 23 '11 at 11:03

When you use the starred version the reference counter is not updated. If you don't want numbering below subsection, just change the secnumdepth counter. The following code demonstrates this:

\section{Section 1}
\subsection{subsection 1}
\subsubsection{subsubsection 1}
  This should be unnumbered.
\subsubsection{subsubsection 2}
  See subsubsection~\nameref{subsubsec:1}

Resulting in:

referencing unnumbered subsubsection by name

  • 1
    Actually, setting secnumdepth is unnecessary as it's default value is 2. – spet Nov 23 '11 at 11:14
  • Yeah, I already mentioned that in my comment. Just wasn't sure if this was also the case in the report class, since I never really use this class. – Roelof Spijker Nov 23 '11 at 11:18
  • Indeed so :) I'd like to add, that when referencing something unnumbered, it would be very helpful to the reader to include a page reference using \pageref{subsubsec:1}. See the package varioref where \vpageref{subsubsec:1} results in something akin on the preceding page instead of a page number where appropriate. – spet Nov 23 '11 at 11:34
  • Works like a dream, thanks. Nice thing with \hyperref is that it already includes \nameref and creates links to the actual paragraph, but indeed pageref makes it more usable for the readers of printed version. I might have a non-standard report class but it needed this secnumdepth setting. But now it's working correctly! – Lopo Nov 23 '11 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.