2

The following KOMA-Script/LuaLaTeX document:

\documentclass{scrbook}
\usepackage[nameinlink]{cleveref}
\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:

A clever reference with a missing name

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:

When the setcounter line is commented out, 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).

2
  • 3
    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, 2018 at 14:35
  • 3
    The issue is not KOMA-Script related. You will get the same issue with a standard class.
    – esdd
    Oct 31, 2018 at 14:39

1 Answer 1

3

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

\documentclass{scrbook}
\usepackage[nameinlink]{cleveref}
\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}

enter image description here

3
  • Thank you. One question, though. Why the capital C in \Crefname? Can I use \crefname instead?
    – Evan Aad
    Oct 31, 2018 at 14:42
  • 2
    @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. Oct 31, 2018 at 14:51
  • 2
    @EvanAad If you decide to define \cnameref you should give the lower case name. Oct 31, 2018 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .