我已阅读了许多其他关于 PDF 书签的错误链接锚点的帖子,但这些建议对我来说不起作用,或者我不理解它们。
我有以下文档,我想为其添加 PDF 书签。但各部分的 PDF 书签指向错误的页面——它们指向页面前他们应该去的那个。但这只发生在以前的部分有子章节——如果前一节没有子节,则章节书签将转到正确的页面。
\clearpage
我认为这与我使用 来设计部分样式中的 s有关titlesec
。我希望将部分标题放在其自己的页面上,但我不知道如何在执行此操作时让书签工作。据我所知,子部分和子子部分(此处未显示)的书签工作正常。
MWE 紧随其后。
\documentclass[12pt]{article}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage[margin=1.0in]{geometry}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\linespread{1.05}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\titleformat{\section}[display]%
{\clearpage\filcenter\Huge\bfseries\scshape}%
{\vspace*{\fill}}{0pt}{}[\vspace*{\fill}\thispagestyle{empty}\clearpage]
\titleformat{\subsection}{\Large\bfseries}{}{6pt}{}
\titleformat{\subsubsection}{\large\bfseries}{}{12pt}{}
\usepackage[stable]{footmisc}
\usepackage{xcolor}
\definecolor{navyblue} {RGB}{0. ,0. ,139.}
\usepackage[hyperfootnotes=false]{hyperref}
\hypersetup{%
colorlinks=true,
breaklinks,
citecolor=black,
filecolor=black,
linkcolor=red,
urlcolor=navyblue,
urlbordercolor=navyblue%
}
\title{Sample Doc}
\author{Me}
\date{\today}
\begin{document}
\maketitle
\thispagestyle{empty}
\tableofcontents
% -----------------------------------------------------------
\section{Section 1}
% -----------------------------------------------------------
\subsection{Subsection 1}
% -----------------------------------------------------------
\section{Section 2}
% -----------------------------------------------------------
\subsection{Subsection 1}
\subsection{Subsection 2}
% -----------------------------------------------------------
\section{Section 3}
% -----------------------------------------------------------
% -----------------------------------------------------------
\section{Section 4}
% -----------------------------------------------------------
\subsection{Subsection 1}
\subsection{Subsection 2}
\subsection{Subsection 3}
% -----------------------------------------------------------
\section{Section 5}
% -----------------------------------------------------------
\subsection{Subsection 1}
\subsection{Subsection 2}
\subsection{Subsection 3}
\end{document}
答案1
\clearpage
只需从标题格式中 删除第一个即可。
\documentclass[12pt]{article}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage[margin=1.0in]{geometry}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage[stable]{footmisc}
\usepackage{xcolor}
\usepackage[hyperfootnotes=false]{hyperref}
\linespread{1.05}
\let\oldsection\section
\renewcommand{\section}{\clearpage\oldsection} % put the first clearpage here
\titleformat%
{\section}%
[display]%
{\filcenter\Huge\bfseries\scshape}%
{}%
{0pt}%
{\vspace*{\fill}}%
[\vspace*{\fill}\thispagestyle{empty}\clearpage] % second clearpage stays here
\titleformat{\subsection}{\Large\bfseries}{}{6pt}{}
\titleformat{\subsubsection}{\large\bfseries}{}{12pt}{}
\definecolor{navyblue} {RGB}{0. ,0. ,139.}
\hypersetup{%
colorlinks=true,
breaklinks,
citecolor=black,
filecolor=black,
linkcolor=red,
urlcolor=navyblue,
urlbordercolor=navyblue%
}
\title{Sample Doc}
\author{Me}
\date{\today}
\begin{document}
\maketitle
\thispagestyle{empty}
\tableofcontents
\section{Section 1}
\subsection{Subsection 1}
\section{Section 2}
\subsection{Subsection 1}
\subsection{Subsection 2}
\section{Section 3}
\section{Section 4}
\subsection{Subsection 1}
\subsection{Subsection 2}
\subsection{Subsection 3}
\section{Section 5}
\subsection{Subsection 1}
\subsection{Subsection 2}
\subsection{Subsection 3}
\end{document}