书签指向错误的页面 - 索引页指向封面页

书签指向错误的页面 - 索引页指向封面页

我正在使用带有书签包的 KOMA scrbook 类。插入\hypertaget{}索引页时,它错误地指向文档的第一页,如下图所示。

我想问两个问题:

  1. 下面的代码示例有什么问题。

  2. 查看我经常看到的针对此问题的各种解决方案clearpagethispagestyle{empty}这些命令的用途是什么?

谢谢约翰

在此处输入图片描述

代码示例(使用 miktex-portable-2.9.6361 编译)

\documentclass[twoside=false]{scrbook}
\usepackage[letterpaper]{geometry}

\usepackage{lipsum}
\usepackage{tikz}

\usepackage{makeidx}
\makeindex

\usepackage{bookmark}
\hypersetup
{
    hidelinks, % Remove red boxes
    linkbordercolor=0 1 0,
    colorlinks=false,
    bookmarksnumbered=true,
}

\renewcommand*{\thechapter}{
  \texorpdfstring{}{\chaptername\space}\arabic{chapter}
  \texorpdfstring{}{: }
}

\renewcommand*{\thesection}{
  \arabic{chapter}.\arabic{section}
}

\begin{document}

\frontmatter

%--------------------------------
% 1. Cover (frontmatter)
%--------------------------------

\begingroup
  \hypertarget{Cover}{}
  \bookmark[level=chapter,dest=Cover]{Cover}
  \thispagestyle{empty}
  \begin{tikzpicture}[remember picture,overlay]
    \draw (current page.center) node []{\Huge\centering\bfseries\sffamily\parbox[c][][t]{\paperwidth}{\centering Lorem ipsum dolor\\[18pt]
    {\Large  Consectetuer adipiscing elit}\\[20pt] 
    {\huge J. Appleseed \& B. Doe}}};
  \end{tikzpicture}
  \vfill
\endgroup

\clearpage
\thispagestyle{empty}
%--------------------------------
% 2. Copyright (frontmatter)
%--------------------------------
\chapter{Copyright}
Copyright 2017 by Authors\\

\noindent This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) license. This license is available at\\
\noindent http://creativecommons.org/licenses/by-nc-sa/3.0/

%----------------------------------------------------------------------------------------
% About the Author (frontmatter)
%----------------------------------------------------------------------------------------
\chapter{About the Authors}
\textbf{Johnny Appleseed}
\lipsum[30]

\bigskip

\noindent \textbf{Bob Doe}
\lipsum[31]

\clearpage
\thispagestyle{empty}
%----------------------------------------------------------------------------------------
% Table of contents (frontmatter)
%----------------------------------------------------------------------------------------
\hypertarget{tableofcontents}{}
\bookmark[level=chapter,dest=tableofcontents]{Table of Contents}
\tableofcontents

%----------------------------------------------------------------------------------------
% Foreword (frontmatter)
%----------------------------------------------------------------------------------------
\chapter{Foreword}
\lipsum[1-3]

%----------------------------------------------------------------------------------------
% Mainmatter
\mainmatter
%----------------------------------------------------------------------------------------

\chapter{Lorem ipsum}

Nunc sapien\index{Sapien} leo, fringilla\index{Fringilla} ut nulla quis, ornare efficitur libero. Aliquam erat volutpat. Sed id mauris et felis commodo scelerisque. Curabitur eu vehicula dolor. Sed facilisis enim magna, a commodo orci auctor fringilla. Praesent egestas lacinia lobortis. Curabitur fermentum eleifend arcu\index{Arcu} sed ornare. Pellentesque semper, lorem id hendrerit luctus, eros urna bibendum sapien, cursus consequat enim nunc vitae urna. Aenean bibendum, libero eget posuere iaculis, tortor ipsum porttitor enim, vitae\index{Vitae} sollicitudin dolor urna at ipsum. Fusce ut rutrum arcu. Praesent luctus sem nisi, ac sagittis\index{Sagittis} nulla lacinia ac. Curabitur ultricies massa a lectus sagittis dignissim. 

\chapter{Sed commodo}
Praesent in laoreet lorem. Pellentesque nec dolor molestie, accumsan justo non, pulvinar odio. Nunc scelerisque urna placerat bibendum molestie. Vivamus mollis\index{Mollis} nec ex in pellentesque. Vivamus sagittis tortor eu dui vulputate, nec tempor massa porttitor. Phasellus convallis nunc vitae\index{Vitae} erat hendrerit, quis rutrum turpis maximus. Mauris pharetra leo eget consectetur sodales. Donec sed justo in enim congue dignissim ac at libero. Vestibulum interdum mattis hendrerit. Nullam interdum, tellus nec ornare scelerisque, sem magna auctor nulla, nec tempus eros risus et sem. Sed iaculis ipsum quis risus porta maximus. In sed quam eu nunc mattis porttitor in id arcu. Fusce vestibulum dolor vestibulum ipsum condimentum, a ullamcorper nisl consequat. Quisque quis elementum leo. 


%----------------------------------------------------------------------------------------
% Backmatter
% Index must be in arabic numbers
% \backmatter
%----------------------------------------------------------------------------------------

\printindex
\hypertarget{Index}{}
\bookmark[level=chapter,dest=Index]{Index}


\end{document}

答案1

\documentclass[twoside=false]{scrbook}
\usepackage[letterpaper]{geometry}

\usepackage{lipsum}
\usepackage{tikz}

\usepackage{imakeidx}
\makeindex[columns=1,intoc]

\usepackage{bookmark}
\hypersetup
{
    hidelinks, % Remove red boxes
    linkbordercolor=0 1 0,
    colorlinks=false,
    bookmarksnumbered=true,
}

\renewcommand*{\thechapter}{%
  \texorpdfstring{}{\chaptername\space}\arabic{chapter}%
  \texorpdfstring{}{: }%
}

\renewcommand*{\thesection}{%
  \arabic{chapter}.\arabic{section}
}

\begin{document}

\frontmatter

%--------------------------------
% 1. Cover (frontmatter)
%--------------------------------

\begingroup
  \hypertarget{Cover}{}
  \bookmark[level=chapter,dest=Cover]{Cover}
  \thispagestyle{empty}
  \begin{tikzpicture}[remember picture,overlay]
    \draw (current page.center) node []{\Huge\centering\bfseries\sffamily\parbox[c][][t]{\paperwidth}{\centering Lorem ipsum dolor\\[18pt]
    {\Large  Consectetuer adipiscing elit}\\[20pt] 
    {\huge J. Appleseed \& B. Doe}}};
  \end{tikzpicture}
  \vfill
\endgroup

\clearpage
\thispagestyle{empty}
%--------------------------------
% 2. Copyright (frontmatter)
%--------------------------------
\chapter{Copyright}
Copyright 2017 by Authors\\

\noindent This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) license. This license is available at\\
\noindent http://creativecommons.org/licenses/by-nc-sa/3.0/

%----------------------------------------------------------------------------------------
% About the Author (frontmatter)
%----------------------------------------------------------------------------------------
\chapter{About the Authors}
\textbf{Johnny Appleseed}
\lipsum[30]

\bigskip

\noindent \textbf{Bob Doe}
\lipsum[31]

\clearpage
\thispagestyle{empty}
%----------------------------------------------------------------------------------------
% Table of contents (frontmatter)
%----------------------------------------------------------------------------------------
\hypertarget{tableofcontents}{}
\bookmark[level=chapter,dest=tableofcontents]{Table of Contents}
\tableofcontents

%----------------------------------------------------------------------------------------
% Foreword (frontmatter)
%----------------------------------------------------------------------------------------
\chapter{Foreword}
\lipsum[1-3]

%----------------------------------------------------------------------------------------
% Mainmatter
\mainmatter
%----------------------------------------------------------------------------------------

\chapter{Lorem ipsum}

Nunc sapien\index{Sapien} leo, fringilla\index{Fringilla} ut nulla quis, ornare efficitur libero. Aliquam erat volutpat. Sed id mauris et felis commodo scelerisque. Curabitur eu vehicula dolor. Sed facilisis enim magna, a commodo orci auctor fringilla. Praesent egestas lacinia lobortis. Curabitur fermentum eleifend arcu\index{Arcu} sed ornare. Pellentesque semper, lorem id hendrerit luctus, eros urna bibendum sapien, cursus consequat enim nunc vitae urna. Aenean bibendum, libero eget posuere iaculis, tortor ipsum porttitor enim, vitae\index{Vitae} sollicitudin dolor urna at ipsum. Fusce ut rutrum arcu. Praesent luctus sem nisi, ac sagittis\index{Sagittis} nulla lacinia ac. Curabitur ultricies massa a lectus sagittis dignissim. 

\chapter{Sed commodo}
Praesent in laoreet lorem. Pellentesque nec dolor molestie, accumsan justo non, pulvinar odio. Nunc scelerisque urna placerat bibendum molestie. Vivamus mollis\index{Mollis} nec ex in pellentesque. Vivamus sagittis tortor eu dui vulputate, nec tempor massa porttitor. Phasellus convallis nunc vitae\index{Vitae} erat hendrerit, quis rutrum turpis maximus. Mauris pharetra leo eget consectetur sodales. Donec sed justo in enim congue dignissim ac at libero. Vestibulum interdum mattis hendrerit. Nullam interdum, tellus nec ornare scelerisque, sem magna auctor nulla, nec tempus eros risus et sem. Sed iaculis ipsum quis risus porta maximus. In sed quam eu nunc mattis porttitor in id arcu. Fusce vestibulum dolor vestibulum ipsum condimentum, a ullamcorper nisl consequat. Quisque quis elementum leo. 


%----------------------------------------------------------------------------------------
% Backmatter
% Index must be in arabic numbers
% \backmatter
%----------------------------------------------------------------------------------------

\printindex
%\bookmark[level=chapter,dest=Index]{Index}


\end{document}

相关内容