我的文件编号如下
- 1
- 1.1
- 1.1.1
- A
- 乙
- 1.1.2
- A
- 乙
子小节没有像小节那样完整的编号。但是,我希望子小节的链接显示为 1.1.1B。是否可以创建一个执行此操作的命令?如果我执行 \ref{label_subsubsectionA},我只会得到 A。但是,我如何获取相应子小节的小节编号?以下是代码:
\documentclass{book}
\setcounter{secnumdepth}{4}
\makeatletter
\renewcommand\thesubsubsection{\Alph{subsubsection}}
\makeatother
\begin{document}
\mainmatter
\chapter{The chapter title}
\section{A section title}
\subsection{A subsection title}\label{B}
\subsubsection{A subsubsection level}\label{A}
Current Subsubsection citation "\ref{A}". However, it should appear like
this: "\ref{B}\ref{A}".
\end{document}
虽然我可以使用这两个 \ref 命令来做到这一点,但它确实会导致错误的超链接
答案1
更新标签p
前缀以包含\thesubsection
:
\documentclass{book}
\setcounter{secnumdepth}{4}
\makeatletter
\renewcommand{\thesubsubsection}{\Alph{subsubsection}}% Subsubsection counter representation
\renewcommand{\p@subsubsection}{\thesubsection}% Subsubsection label prefix
\makeatother
\begin{document}
\mainmatter
\chapter{The chapter title}
\section{A section title}
\subsection{A subsection title}\label{B}
\subsubsection{A subsubsection level}\label{A}
Current Subsubsection citation: ``\ref{A}''
\end{document}