Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

\phantomsection
\addcontentsline{toc}{subsubsection}{My title}
\subsubsection*{My title}
\label{sec:mysection}

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

share|improve this question
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

1 Answer 1

up vote 5 down vote accepted

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:

\documentclass{report}
\usepackage{nameref}
\begin{document}
\setcounter{secnumdepth}{2}
\section{Section 1}
\subsection{subsection 1}
\subsubsection{subsubsection 1}
  \label{subsubsec:1}
  This should be unnumbered.
\subsubsection{subsubsection 2}
  See subsubsection~\nameref{subsubsec:1}
\end{document}

Resulting in:

referencing unnumbered subsubsection by name

share|improve this answer
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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