\section
북마크 를 만들면 \section*
앵커가 다른 위치에 있는 두 섹션을 가리킵니다. 작은 수직 공간이 추가됩니다 \section*
( .png
-files 참조). 앵커가 같은 위치에 있는지 어떻게 확인할 수 있나요?
나는 다음을 만들고 싶기 때문에 이 솔루션이 필요합니다.부록 목록LoA
, 항목은 와 에만 표시되어야 ToC
하지만 텍스트와 에는 여전히 섹션 번호가 필요합니다 LoA
.
\documentclass{book}
\usepackage{bookmark}
\hypersetup{bookmarksnumbered=true}
\begin{document}
\chapter{Chapter one}
References here:
ref: \ref{chap2} (chapter)
ref: \ref{chap2sec1} (section)
ref: \ref{chap2sec2} (star-section)
\chapter{Chapter two}\label{chap2}
...(contents of chapter 2)...
\section{Sec one}\label{chap2sec1}
...(contents of chapter 2 - section 1)...
\refstepcounter{section}
\section*{\thesection{}{\quad}Sec two}\label{chap2sec2}
\addcontentsline{toc}{section}{\protect\numberline{\thesection}Sec two}
...(contents of chapter 2 - section 2)...
\end{document}
편집 (1):에 대한 잘못된 북마크 앵커를 표시하기 위해 빨간색 상자를 추가했습니다 \section*
. 섹션 사이의 간격은 정확하고 앵커 설정만 잘못되었습니다.
답변1
몇 가지 사소한 수정만으로 \section
작동 방식을 조정 하고 \section*
동일한 방식으로 작동 하도록 할 수 있습니다.\section
\documentclass{book}
\usepackage{bookmark}
\hypersetup{bookmarksnumbered=true}
\usepackage{xparse}
\makeatletter
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname\space}% Just for this example
\let\oldsection\section
\let\oldaddcontentsline\addcontentsline
\RenewDocumentCommand{\section}{s o m}{%
\IfBooleanTF{#1}
{{% \section*
\renewcommand{\refstepcounter}[1]{\phantomsection}% Gobble counter stepping
\renewcommand{\@seccntformat}[1]{}% Gobble section number formatting
\renewcommand{\addcontentsline}[3]{\oldaddcontentsline{toc}{section}{#3}}% Next entry _will_ be a section
\oldsection{#3}% \section*[.]{..}
}}{% \section
\IfNoValueTF{#2}
{\oldsection{#3}}% \section{..}
{\oldsection[#2]{#3}}% \section[.]{..}
}%
}
\makeatother
\begin{document}
\chapter{Chapter one}
References here:
ref: \ref{chap2} (chapter)
ref: \ref{chap2sec1} (section)
ref: \ref{chap2sec2} (star-section)
\chapter{Chapter two}\label{chap2}
...(contents of chapter 2)...
\section{Sec one}\label{chap2sec1}
...(contents of chapter 2 - section 1)...
\stepcounter{section}%
\section*{\thesection{} Sec two}\label{chap2sec2}
...(contents of chapter 2 - section 2)...
\end{document}
xparse
\section
일반적으로 별표 버전, 선택 및 필수 인수 로 관리되는 인수를 쉽게 캡처하는 데 사용됩니다 .
\section*
호출 되면 다음과 같은 일반적인 세 가지 사항을 업데이트합니다 \section*
.
카운터 스테핑은
\refstepcounter
무작동으로 이루어집니다.섹션 카운터 서식 지정 매크로는
\@seccntformat
무작동으로 변환됩니다.내용 관련 글쓰기는 입력에 맞게 업데이트되므로
\numberline
인쇄가 방지됩니다.
에서는 헤더 인쇄(즉, 내부적으로)에 동일한 절차를 사용하므로 \section
출력 하이퍼링크가 동일한 수직 위치로 이동합니다.\section*
\@sect
\refstepcounter
귀하의 예는 섹션 2.2의 일부로 매뉴얼을 포함하고 있으므로 약간 조작되었습니다 . 그러나 위에 정의된 업데이트된 버전을 사용하는 하이퍼링크 점프에는 아무런 문제가 없습니다 \section
.