목차의 하이퍼링크 수정

목차의 하이퍼링크 수정

hyperref클릭 가능한 링크가 있도록 패키지를 사용하고 있습니다 \tableofcontents.

강제로 하는 방법이 있나요?하나\tableofcontents자동으로 선택된 페이지 대신 특정 페이지를 참조하도록 하이퍼링크를 설정하시겠습니까 ?

PDF 출력의 2페이지에서 시작하는 장이 있지만 대신 3페이지를 표시하는 클릭 가능한 링크를 생성하기 위해 목차를 원한다고 가정해 보겠습니다.

(여기서 일반적인 답변을 찾고 있으므로 코드/헤더가 없습니다)

답변1

아마도 나는 질문을 완전히 오해했을 것입니다.

hyperlink장 항목처럼 보이지만 장의 시작 페이지가 아닌 다른 곳을 가리키는 항목이 있어야 합니다 .

\nottocchapter나는 일반적인 번호가 매겨진 챕터처럼 작동하지만 거기서 쫓겨나는 작업을 수행했습니다 \addcontentsline.

\lookslikeachapterentrybutpointstosomewhereelse그런 다음 나중에 관련 장 항목을 표시되는 페이지 번호와 함께 추가하는 이름을 정의했습니다 (사용자가 적절한 것을 잘못 사용하는 것은 고통스럽습니다 ;-).

이 모든 것을 추천합니까? 아니요 ;-)

\documentclass{book}

\usepackage{blindtext}
\usepackage{xparse}


\makeatletter

\let\latex@chapter\chapter

\def\currentchaptername{}

\NewDocumentCommand{\notocchapter}{om}{%
  \IfValueTF{#1}{%
    \def\currentchaptername{#1}
  }{%
    \def\currentchaptername{#2}
  }%
  \begingroup
  \renewcommand{\addcontentsline}[3]{}% Do nothing for this chapter
  \IfValueTF{#1}{%
    \latex@chapter[#1]{#2}
  }{%
    \latex@chapter{#2}
  }%
  \endgroup
}

\NewDocumentCommand{\lookslikeachapterentrybutpointstosomewhereelse}{o}{%
  \phantomsection
  \IfValueTF{#1}{%
    \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
  }{%
    \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}\currentchaptername}
  }%
}

\makeatother

\usepackage[linktocpage]{hyperref}


\begin{document}

\tableofcontents

\notocchapter{Some chapter}

\blindtext[20] 

\lookslikeachapterentrybutpointstosomewhereelse

\chapter{Some other chapter}

\notocchapter{Another chapter}

\blindtext[40] 

\lookslikeachapterentrybutpointstosomewhereelse[And now for something completely different]


\end{document}

관련 정보