When referring to subordinated sections, cleverref by default shows the identifier of the referred section as it is actually displayed in full text. I redefined the \part, \chapter, ... commands to display only the identifier of the actual section. Is there a way to show the identifiers of the superordinated section, chapter, part ... as well? Cleveref does not seem to have an option for this and unfortunately I was not able to investigate a solution on my own.

Here is my MWE to demonstrate what I am looking for:

\documentclass[fontsize=12pt, a4paper]{scrreprt}




\part{First Part}

\chapter{First Chapter}
Is: For further information see \cref{first_subsection}.

Should be: For further information see section B.II.1.a.

\section{First Section}

\part{Second Part}

\chapter{Second Chapter}

\section{Second Section}

\subsection{First Subsection}
Is: As noticed in \cref{first_chapter} ...

Should be: As noticed in A.I. ...

  • Welcome to TeX.SE. – Mico Mar 7 at 8:18

LaTeX provides a built-in mechanism for adding the "prefixes" of subordinated units to cross-reference call-outs. If a counter called, say, mycounter is created, LaTeX automatically creates a macro called \p@mycounter which contains the material to be prefixed in a cross-reference to an instance of mycounter.

By default, this "prefix macro" is empty, i.e., it inserts no material. However, if you add the instructions

\renewcommand{\p@chapter}{\thepart.} % prefix for chapter-level cross-refs
\renewcommand{\p@section}{\p@chapter\thechapter.} % prefix for section-level cross-refs
\renewcommand{\p@subsection}{\p@section\thesection.} % for cross-refs to subsections
\renewcommand{\p@subsubsection}{\p@subsection\thesubsection.} % for cross-refs to subsubsections

to the preamble of your document, all cross-references generated by \cref (and, for that matter, \ref as well) to chapters, sections, subsections, and subsubsections will employ the full composite numbers.

| improve this answer | |
  • 1
    Thank you! That is exactly what I was looking for. And I even learned about the counter mechanism. – zord Mar 7 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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