章節和目錄超連結之前的分頁符號問題

章節和目錄超連結之前的分頁符號問題

\section{...}我的每個文件之前都需要分頁。根據這個線程:每個部分開始新頁面我應該添加以下命令:

\newcommand{\sectionbreak}{\clearpage} % page break before section

toc但使用with有一個問題hyperref。每個部分的超連結toc設定在其實際頁面位置之前的一頁。在以下範例中:

  • 如果toc我點擊的超連結第1節(這是在第2頁),我會繼續第 1 頁
  • 如果toc我點擊的超連結第2節(這是在第3頁),我將被帶到第2頁

這是準備測試的程式碼:

\documentclass[12pt,a4paper]{scrartcl} % A4 paper and 12pt font size

\usepackage{hyperref} % Hyperlinks
\usepackage{titlesec} % customizing sections

\newcommand{\sectionbreak}{\clearpage} % page break before section

\begin{document}

\tableofcontents

\section{Section 1}
Text
\subsection{Subsection 1.1}
Text
\subsection{Subsection 1.2}
Text

\section{Section 2}
Text
\subsection{Subsection 2.1}
Text
\subsection{Subsection 2.2}
Text
Text

\end{document}

我需要修復錯誤的鏈接,toc或者需要一些在節之前插入分頁符的其他方法,這與超鏈接兼容toc

答案1

兩個都hyperreftitlesec操縱重要的、有關的文檔的元素。因此,應始終考慮載入順序。在這種情況下,載入順序應類似於

\usepackage{titlesec}
...
\usepackage{hyperref}

正如隱性暗示的hyperref哪些包應該在之後而不是之前加載?。然而,你也會發現memoir.log在關於載入中提及以下內容titlesec

Class scrartcl Warning: Usage of package `titlesec' together
(scrartcl)              with a KOMA-Script class is not recommended.
(scrartcl)              I'd suggest to use the package only
(scrartcl)              if you really need it, because it breaks several
(scrartcl)              KOMA-Script features, i.e., option `headings' and
(scrartcl)              the extended optional argument of the section
(scrartcl)              commands .
(scrartcl)              Nevertheless, using requested
(scrartcl)              package `titlesec' on input line 4.

雖然套件旨在擴展文件類別所施加的某些“限制”,但memoir應考慮提供其自己的功能的靈活類別(如 )。

相關內容