更改子部分编号而不更改 cleveref 编号

更改子部分编号而不更改 cleveref 编号

我设法使用以下命令更改子部分编号:

\renewcommand*{\thesubsubsection}{\arabic{subsubsection}.}

然而,cleveref 的\Cref{mysubsubsection}回归Section 1.

我想要一个像Section x.y.z.1

分数维:

\documentclass{article}
\usepackage[utf8]{inputenc}
\renewcommand*{\thesubsubsection}{\arabic{subsubsection}.}
\usepackage[nameinlink, french]{cleveref}

\begin{document}
\section{My Section}
\subsection{My subsection}
\subsubsection{My subsubsection}\label{mysubsubsection}
My section ref is : \Cref{mysubsubsection} and I would like to be "Section 1.1.1"
\end{document}

结果 :

在此处输入图片描述

答案1

这应该适用于大多数交叉引用包,因为它会更新主要引用组件以及显示组件LaTeX 内核

在此处输入图片描述

\documentclass{article}

\makeatletter
\renewcommand{\thesubsubsection}{\arabic{subsubsection}}
\renewcommand{\p@subsubsection}{\thesubsection.}
\renewcommand{\@seccntformat}[1]{%
  \csname the#1\endcsname
  \ifnum\pdfstrcmp{#1}{subsubsection}=0 .\fi% If this is a subsubsection, add a period
  \quad}
\makeatother

\usepackage[nameinlink]{cleveref}

\begin{document}

\section{My Section}

\subsection{My subsection}

\subsubsection{My subsubsection}\label{sssec:mysubsubsection}

My section ref is : \Cref{sssec:mysubsubsection} and I would like to be ``Section 1.1.1''.

\end{document}

相关内容