我希望每个章节都以个性化的部分目录开始(我使用 titletoc 实现了这个功能)。
当我编译时出现以下错误:
出了点问题——可能缺少了 \item
我已经完成了 MWE:
\documentclass[11pt,
a4paper,
twoside]{report}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Package import
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[top=2.5cm,
bottom=2.5cm,
inner=2.5cm,
outer=3cm,
twoside]{geometry}
\usepackage[usenames,
dvipsnames]{xcolor}
\usepackage{titletoc}
\usepackage[hidelinks,
colorlinks = true,
linkcolor = PineGreen,
urlcolor = PineGreen,
citecolor = PineGreen,
anchorcolor = PineGreen,
allcolors = PineGreen]{hyperref}
\usepackage{subfiles}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Redefine TOC Style
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chapter text styling
\titlecontents{chapter}[1.25cm] % Indentation
{\addvspace{12pt}\Large\bfseries} % Spacing and font options for chapters
{\color{BrickRed}\contentslabel[\thecontentslabel]{1.25cm}\color{BrickRed}} % Chapter number
{\color{BrickRed}}
{\hfill\color{BrickRed}\thecontentspage} % Page number
% Section text styling
\titlecontents{section}[1.25cm] % Indentation
{\addvspace{3pt}\bfseries} % Spacing and font options for sections
{\contentslabel[\thecontentslabel]{1.25cm}} % Section number
{}
{\hfill\color{black}\thecontentspage} % Page number
[]
% Subsection text styling
\titlecontents{subsection}[1.25cm] % Indentation
{\addvspace{1pt}} % Spacing and font options for subsections
{\contentslabel[\thecontentslabel]{1.25cm}} % Subsection number
{}
{\ \titlerule*[.5pc]{.}\;\thecontentspage} % Page number
[]
% Subsubsection text styling
\titlecontents{subsubsection}[1.25cm] % Indentation
{\addvspace{1pt}\small} % Spacing and font options for subsubsections
{\contentslabel[\thecontentslabel]{1.25cm}} % Subsubsection number
{}
{\ \titlerule*[.5pc]{.}\;\thecontentspage} % Page number
[]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
{
\hypersetup{hidelinks}
\tableofcontents
}
%\subfile{test}
\startcontents[Introduction]
\chapter{Introduction}\label{chap-introduction}
{
\hrulefill
\printcontents[Introduction]{}{1}{}
\vspace{-3mm}
\hrulefill
}
\section{Context}\label{sec-context}
This chapter introduces the context of the project
\stopcontents[Introduction]
\end{document}
我已经进行了一些调查,当在部分目录(在本例中)第一个目录之前有要打印的内容时,会出现此错误\hrulefill
。如果直接有\printcontents
命令,则不会出现错误。
如果我删除个性化的 TOC 样式,则不会出现错误。
我已经在其他文档中使用了这种样式(没有部分目录),并且效果很好...
该错误将我重定向到包含以下内容的 main.ptc 文件:
\babel@toc {english}{}
\ttl@starttoc {Introduction@1}
\contentsline {chapter}{\numberline {1}Introduction}{2}{chapter.1}%
\contentsline {section}{\numberline {1.1}Context}{2}{section.1.1}%
\ttl@stoptoc {Introduction@1}
\contentsfinish
你们有人知道它是从哪里来的吗?
提前致谢 :)