[Tex/LaTex] Reference to an unnumbered section

cross-referencinghyperrefnumberingsectioning

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?

Best Answer

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

Related Question