# The name of a cleveref reference is missing when the reference is inside a subsubsection of an appendix

The following KOMA-Script/LuaLaTeX document:

\documentclass{scrbook}
\setcounter{secnumdepth}{4}
\begin{document}
\appendix
\chapter{Chapter}
\section{Section}
\subsection{Subsection}\label{sub}
\cref{sub}
\subsubsection{Subsubsection}\label{subsub}
\cref{subsub}
\end{document}


prints thus:

Notice that the name of the reference in the subsubsection is missing, unlike the reference in the subsection.

If I increase the number argument for \setcounter (say, to 6, or 10), the output is the same. However, if I comment out the line \setcounter{secnumdepth}{4} altogether, the problem resolves:

Why is it? Is there a way to solve the problem without commenting out the \setcounter line? The reason why I don't want to comment out the \setcounter line, is because in my actual document (not the sample one listed above), this line serves some purpose (though I'm not sure what this purpose is).

• As samcarter's answer shows, the problem is that subsubsubappendix (subsubsection on an appendix level) has no cref string definition. If you remove the \setcounter{secnumdepth}{4} and let it fall back to the default (\setcounter{secnumdepth}{3}?) the \subsubsection is not numbered and so both \labels refer to the same thing, namely the \subsection (the purpose of secnumdepth is to control which levels of sectioning get numbered). So the issue would still be there in the last example it just is not visible. – moewe Oct 31 '18 at 14:35
• The issue is not KOMA-Script related. You will get the same issue with a standard class. – esdd Oct 31 '18 at 14:39

You can add a definition for the 4th appendix level:

\documentclass{scrbook}
\setcounter{secnumdepth}{4}

\Crefname{subsubsubappendix}{Appendix}{Appendices}%

\begin{document}
\appendix
\chapter{Chapter}
\section{Section}
\subsection{Subsection}\label{sub}
\cref{sub}
\subsubsection{Subsubsection}\label{subsub}
\cref{subsub}
\end{document}


• Thank you. One question, though. Why the capital C in \Crefname? Can I use \crefname instead? – Evan Aad Oct 31 '18 at 14:42
• @EvanAad If only one of \cnameref or \Cnameref is defined cleverref automatically defines the other one as the lower/uppercase variant of it, so it should not really make any difference as long as your names start with normal letters. To be on the save side, you can define both. – user36296 Oct 31 '18 at 14:51
• @EvanAad If you decide to define \cnameref you should give the lower case name. – user36296 Oct 31 '18 at 14:52