目录 各部分的章节链接指向前几部分的章节

目录 各部分的章节链接指向前几部分的章节

在目录中,当我单击各个部分的章节时,我最终会转到上一部分的章节。因此,当我单击第 2 部分的第 1 章时,我会转到第 1 部分的第 1 章,因为它是第 1 章。第 2 部分的第 1 章位于第 2 部分这一点似乎没有被考虑在内。因此,当我单击第 3 部分的第 2 章时,我会转到第 1 部分的第 2 章,依此类推,如下所示:

  • 第 1 部分第 1 章 ----> 第 1 部分第 1 章
  • 第 1 部分第 2 章 ----> 第 1 部分第 2 章
  • 第 2 部分第 1 章 ----> 第 1 部分第 1 章
  • 第 2 部分第 2 章 ----> 第 1 部分第 2 章
  • 第 2 部分第 3 章 ----> 第 2 部分第 3 章
  • 第 3 部分第 1 章 ----> 第 1 部分第 1 章
  • 第 3 部分第 2 章 ----> 第 1 部分第 2 章
  • 第 3 部分第 3 章 ----> 第 2 部分第 3 章
  • 第 3 部分第 4 章 ----> 第 3 部分第 4 章

感谢您查看这个。

% PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[oneside,centered,twocolumn]{book}
\usepackage[T1]{fontenc}
\special{papersize=215.9mm,279.4mm}
\usepackage[english]{babel}

\usepackage[sc]{mathpazo}
\linespread{1.05} % Palladio needs more leading

\usepackage{tocloft} % Customization of TOC LOF LOT

\makeatletter\@addtoreset{chapter}{part}\makeatother%

%\usepackage[table,xcdraw]{xcolor} % For shading in tables
\usepackage[toc,page]{appendix}
\usepackage{xcolor} % For links color
\usepackage{multirow}

\usepackage{epigraph}
\usepackage{caption} % To change way captions are labelled
\usepackage{pdfpages}
\usepackage{ltablex}
\usepackage{nicefrac} % to write fractions
\usepackage{attrib} % For source of quotations
\usepackage{lettrine} % For NewThought formatting
\usepackage{array} % To define width of columns in long table
\usepackage{booktabs} % Nicer spacing in columns
\usepackage{siunitx} % To write Celsius, etc.
\usepackage{enumitem} % To create item lists

\usepackage{scrextend}
\usepackage{threeparttable} % For table notes + To allow footnote material to stay with the tabular environment
\usepackage{etoolbox} % To make table footnote font smaller
\usepackage{threeparttablex}
\appto\TPTnoteSettings{\footnotesize}
\usepackage{textcomp} % For Numero symbol
\usepackage{titlesec}

\usepackage{colortbl} % To define colors
\usepackage[linguistics,edges]{forest}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella} % Palatino clone
\setsansfont{Cabin}

% QUOTE TEXT MARGINS + FONT SIZE %%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[font=small,rightmargin=0pt]{quoting}

% FOOTNOTES IN QUOTATION %%%%%%%%%%%%%%%%%%%%

\usepackage[symbol]{footmisc}
%\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}

\usepackage[
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=teal,
urlcolor=teal
]{hyperref} % Hyperlinks

% CHAPTER, SECTION, SUBSECTION STYLE %%%%%%%%%%%%%%%%%%%%%%%%

\newfontfamily\headingfont[]{Cabin}

\begin{document}

    % FRONTMATTER STARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\frontmatter
{
    \hypersetup{linkcolor=blue}\textbf{}
    \renewcommand{\cftdot}{} % This line removes dots for Sections and under
    \tableofcontents
}
\clearpage

\addcontentsline{toc}{section}{\listtablename}
\small{\listoftables}
\clearpage

% MAINMATTER STARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\mainmatter

\part{Part One}

\chapter{Chapter 1 of Part 1}

\chapter{Chapter 2 of Part 1}

\part{Part Two}

\chapter{Chapter 1 of Part 2}

\chapter{Chapter 2 of Part 2}

\chapter{Chapter 3 of Part 2}

\part{Part Three}

\chapter{Chapter 1 of Part 3}

\chapter{Chapter 2 of Part 3}

\chapter{Chapter 3 of Part 3}

\chapter{Chapter 4 of Part 3}

\end{document}

答案1

现在这个问题已经解决了,感谢一些代码:\renewcommand*{\theHchapter}{\thepart.\thebook.\thechapter}

在此处找到:如何重置回忆录类中的分段计数器以避免破坏复杂文档中的目录交叉引用?

我对其进行了一些修改,以使其适应我的书的结构,现在链接可以工作了——在hyperref usepackage提及之后立即添加了代码行。

这是工作代码:

% PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[oneside,centered,twocolumn]{book}
\usepackage[T1]{fontenc}
\special{papersize=215.9mm,279.4mm}
\usepackage[english]{babel}

\usepackage[sc]{mathpazo}
\linespread{1.05} % Palladio needs more leading

\usepackage{tocloft} % Customization of TOC LOF LOT

\makeatletter\@addtoreset{chapter}{part}\makeatother%

%\usepackage[table,xcdraw]{xcolor} % For shading in tables
\usepackage[toc,page]{appendix}
\usepackage{xcolor} % For links color
\usepackage{multirow}

\usepackage{epigraph}
\usepackage{caption} % To change way captions are labelled
\usepackage{pdfpages}
\usepackage{ltablex}
\usepackage{nicefrac} % to write fractions
\usepackage{attrib} % For source of quotations
\usepackage{lettrine} % For NewThought formatting
\usepackage{array} % To define width of columns in long table
\usepackage{booktabs} % Nicer spacing in columns
\usepackage{siunitx} % To write Celsius, etc.
\usepackage{enumitem} % To create item lists

\usepackage{scrextend}
\usepackage{threeparttable} % For table notes + To allow footnote material to stay with the tabular environment
\usepackage{etoolbox} % To make table footnote font smaller
\usepackage{threeparttablex}
\appto\TPTnoteSettings{\footnotesize}
\usepackage{textcomp} % For Numero symbol
\usepackage{titlesec}

\usepackage{colortbl} % To define colors
\usepackage[linguistics,edges]{forest}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella} % Palatino clone
\setsansfont{Cabin}

% QUOTE TEXT MARGINS + FONT SIZE %%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[font=small,rightmargin=0pt]{quoting}

% FOOTNOTES IN QUOTATION %%%%%%%%%%%%%%%%%%%%

\usepackage[symbol]{footmisc}
%\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}

\usepackage[
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=teal,
urlcolor=teal
]{hyperref} % Hyperlinks

\renewcommand*{\theHchapter}{\thepart.\thechapter}

% CHAPTER, SECTION, SUBSECTION STYLE %%%%%%%%%%%%%%%%%%%%%%%%

\newfontfamily\headingfont[]{Cabin}

\begin{document}

    % FRONTMATTER STARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \frontmatter
    {
        \hypersetup{linkcolor=blue}\textbf{}
        \renewcommand{\cftdot}{} % This line removes dots for Sections and under
        \tableofcontents
    }
    \clearpage

    \addcontentsline{toc}{section}{\listtablename}
    \small{\listoftables}
    \clearpage

    % MAINMATTER STARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \mainmatter

    \part{Part One}

    \chapter{Chapter 1 of Part 1}

    \chapter{Chapter 2 of Part 1}

    \part{Part Two}

    \chapter{Chapter 1 of Part 2}

    \chapter{Chapter 2 of Part 2}

    \chapter{Chapter 3 of Part 2}

    \part{Part Three}

    \chapter{Chapter 1 of Part 3}

    \chapter{Chapter 2 of Part 3}

    \chapter{Chapter 3 of Part 3}

    \chapter{Chapter 4 of Part 3}

\end{document}

相关内容