1

As I don't want my sections ... paragraphs to stay unnumbered, I wrote \setcounter{tocdepth}{5} \setcounter{secnumdepth}{0}. With cleveref I cannot refer to unnumbered sections as "section" at all.

To be more clear: I defined a new ref-format \RenewDocumentCommand\fullref{m}{\namecref{#1} \nameref{#1} \vpageref{#1}}, which should give something like "section sectiontitle on page 2" or "subsection sectiontitle on page 4.

% uses-*- MODE: latex; TeX-engine: luatex; coding: utf-8; -*-
\documentclass{scrartcl}
\usepackage[main=ngerman]{babel}
\usepackage[german,final]{varioref}
\usepackage{hyperref}
\usepackage[german,nameinlink]{cleveref}
\makeatletter
\RenewDocumentCommand\fullref{m}{\namecref{#1} \nameref{#1}
  \vpageref{#1}}
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{0} % <---
\makeatother
\begin{document}
\section{I'm Section}
\label{sec:section}
bla

see \namecref{sec:subsubsection}

see \fullref{sec:subsubsection}
\newpage
\subsection{I'm Subsection}
\label{sec:subsection}
bla

bla

see \namecref{sec:section}

see \fullref{sec:section}

see \namecref{sec:subsection}

see \fullref{sec:subsection}
\newpage
\subsubsection{I'm Child of Subsection}
\label{sec:subsubsection}

\end{document}
7
  • 1
    you could try \autoref instead of \namecref. Commented Jul 31, 2023 at 22:54
  • 1
    \label only stores 4 values in the aux file: \@currentlabel, \thepage, \@currentlabelname and \@currentHref. The section title is stored in \@currentlabelname which is a missuse of the entry IMHO. Commented Jul 31, 2023 at 23:14
  • @JohnKormylo \@currentlabelname is meant for the title, it is not a misuse. Commented Aug 1, 2023 at 6:12
  • @JohnKormylo sorry I don't know what you mean. \@currentlabelname is imho used since more than 20 years by nameref, and \@currentcounter was never saved by \label (but you can save it e.g. with zref) Commented Aug 1, 2023 at 12:25
  • OTOH, I have seen people get the counter name by editing \currentHref. This doesn't always work (see tex.stackexchange.com/questions/643473/…). Commented Aug 1, 2023 at 13:01

1 Answer 1

3

You could try the following. This requires a current LaTeX.

\documentclass{scrartcl}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\RenewDocumentCommand\fullref{m}{\namecref{#1} \nameref{#1}
  \vpageref{#1}}

\setcounter{secnumdepth}{0} % <---

\makeatletter
\AddToHookWithArguments{cmd/@sect/before}{\def\cref@currentlabel{[#1][??][??]??}}
\makeatother

\crefname{section}{section}{sections}
\crefname{subsection}{subsection}{subsections}
\crefname{subsubsection}{subsubsection}{subsections}
\begin{document}

\section{I'm Section}\label{sec:section}
bla

see \namecref{sec:subsubsection}, \cref{sec:subsubsection}

see \fullref{sec:subsubsection}
\subsection{I'm Subsection}\label{sec:subsection}
bla
see \namecref{sec:section}

see \fullref{sec:section}

see \namecref{sec:subsection}

see \fullref{sec:subsection}
\subsubsection{I'm Child of Subsection}
\label{sec:subsubsection}
\end{document}

enter image description here

You must log in to answer this question.

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