My document numbers chapters and sections like this:
1. Chapter
1.1 Section
1.1.1 Subsection
Subsubsection
For the first subsection \subsection{First}\label{subsec:first}, for example, cleveref would correctly reference:
As described in \cref{subsec:first}` lorem ipsum...
as
As described in Section 1.1.1 lorem ipsum...
However, since subsubsections do not have numbering, any
\cref{subsubsec:first-subsubsec}
just results in the same
Section 1.1.1
reference.
I would like to have the subsubsection named, so for
\subsubsection{Apples}\label{subsubsec:apples}
...
\subsubref{subsubsec:apples}
It would produce 1.1.1 Apples instead of just 1.1.1 where the reference to the actual subsubsection would get lost.
So far, I implemented this via:
\newcommandx{\subsubref}[1]{\cref{#1} \nameref{#1}}
Is there any way to dynamically decide what is being referenced and treat subsubsections differently?
In simple pseudo-code:
if type of ref == subsubsection:
\cref{#1} \nameref{#1}
else:
\cref{#1}
\creflabelformatline to\creflabelformat{subsubsection}{#2#1 \nameref*{\@lastusedlabel}#3}it gives the desired output. – Marijn Jan 11 '24 at 10:26