\labelformat을 사용하여 레이블에 하위 섹션 제목 포함

\labelformat을 사용하여 레이블에 하위 섹션 제목 포함

에 대한 답변대로이 질문, 부품 및 장 번호를 자동으로 포함하도록 하위 섹션 레이블을 다음과 같이 사용자 정의했습니다.

\labelformat{subsubsection}{Pt~\arabic{part}, Ch~\thechapter, \thesubsubsection}

이는 다음 형식의 레이블을 제공합니다.

1편 2장 3.4.5

이 형식의 일부로 하위 섹션의 제목을 삽입할 수 있습니까? 나는 다음과 같은 것을 상상하고 있습니다 :

\labelformat{subsubsection}{Pt~\arabic{part}, Ch~\thechapter, [code for subsection title] \thesubsubsection}

희망적으로 다음을 제공합니다:

1편, 2장, [하위 제목] 3.4.5

감사합니다.

답변1

그럴 수 있습니다. 아래를 참조하세요. 그러나 나는 그것이 좋은 생각이라고 생각하지 않습니다. 다양한 데이터를 모두 라벨 내에 함께 저장하게 되므로 더 이상 단순히 숫자만 참조할 수 있는 옵션이 없습니다 1.1(예: 이전 섹션만 참조하려는 경우). Imho 데이터를 개별적으로 저장하고 레이블을 참조할 때 복잡한 참조를 작성하려면 zref 또는 새로운 LaTeX 속성을 사용하는 것이 훨씬 좋습니다. 예를 참조하십시오https://tex.stackexchange.com/a/325319/2388.

\documentclass{book}
\usepackage{xr-hyper}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\makeatletter
\labelformat{section}{Pt~\arabic{part}, Ch~\thechapter, \thesection~\@currentlabelname}
\labelformat{subsection}{Pt~\arabic{part}, Ch~\thechapter, \thesubsection~\@currentlabelname}
\makeatother
\begin{document}
\part{}
\label{part: 1}

\chapter{Chapter}
\section{My Section}\label{sec}
\subsection{My Subsection}\label{subsec}

\ref{sec}, \ref{subsec}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보