由于我不希望我的章节...段落保持未编号状态,因此我写道\setcounter{tocdepth}{5} \setcounter{secnumdepth}{0}
。cleveref
我根本无法将未编号的章节称为“章节”。
更清楚一点:我定义了一个新的 ref-format \RenewDocumentCommand\fullref{m}{\namecref{#1} \nameref{#1} \vpageref{#1}}
,它应该给出类似“section章节标题第 2 页”或“小节章节标题在第 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}
答案1
您可以尝试以下操作。这需要当前的 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}