当在 pdflatex 中使用 \part 和 tocloft (没有 fontspec)时,正如本文答案中所建议的那样将书分成几部分和几章,我在目录中的章节编号中遇到了这样的问题。
内容
第一部分
1 第1章
1 章节 1.1
1.1 1.1.1小节
2 第2章
1 第2.1节
1 第2.2节
1.1 第2.2.1节
第二部分
3 第3章
2 第 3.1 节
2.1 第3.1.1节
但文本中的分段很好。
有人能帮帮我吗?谢谢。
序言如下
\documentclass[a4paper,10pt]{book}
\usepackage{amsmath,amssymb,amsfonts,amsthm}
\usepackage{inputenc}
\usepackage{tabularx}
\usepackage{mathtools}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{textcomp}
\usepackage{xpatch}
\usepackage{tikz}
\usepackage{tocloft}
\usepackage{inputenc}
\usepackage{xspace}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{}
\fancyhead[RE,LO]{\textcopyright~ Prints 2019}
\fancyfoot[CE,CO]{}
\fancyfoot[LE,RO]{\thepage}
\everymath{\displaystyle}
\newtheorem{prop}{Proposition}[chapter]
\newtheorem{defn}{Definition}[chapter]
\newtheorem{lemma}{Lemma}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[prop]{Corollary}
\newtheorem{remark}{Remark}
\newtheorem{example}{Example}[chapter]
\newcommand{\floorceil}[1]{\lceil #1 \rfloor}
\makeatletter
\xpatchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}
\makeatother
\renewcommand{\cftpartfont}{\bfseries\Large\hrule}%add line above part
\renewcommand{\cftpartpagefont}{\bfseries}
\renewcommand{\cftbeforepartskip}{5mm}
\renewcommand{\cftpartafterpnum}{\\\hrule}%add line below part
\cftpagenumbersoff{part}%get rid of part page numbers
\renewcommand{\cftsecindent}{8mm}%control spacing between number and sec title
\renewcommand{\cftsecnumwidth}{4mm}%section indent
\renewcommand{\cftparskip}{4mm}%control line spacing
\begin{document}
\tableofcontents
\part{First part}
\chapter{Chapter1}
\section{Sections1.1}
\subsection{Subsection1.1.1}
\chapter{Chapter2}
\section{Section2.1}
\section{Section2.2}
\subsection{Subsection2.2.1}
\part{Second part}
\chapter{Chapter3}
\section{Section3.1}
\subsection{Subsection3.1.1}
\end{document}
目录的快照在这里。]2
答案1
一些意见和建议:
包的长度参数
tocloft
应该通过修改\setlength
,而不是\renewcommand
考虑更换
\renewcommand{\cftsecindent}{8mm}%control spacing between number and sec title \renewcommand{\cftsecnumwidth}{4mm}%section indent
和
\cftsetindents{chap}{0em}{1.5em} \cftsetindents{sec}{1.5em}{2em} \cftsetindents{subsec}{3.5em}{2.75em}
您显然可以自由修改这些设置以满足您的偏好和排版需求。
\documentclass[a4paper,10pt]{book}
\usepackage{mathtools,amssymb,amsthm}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{textcomp}
\usepackage{xpatch}
\usepackage{tikz}
\usepackage{tocloft}
\usepackage{xspace}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{}
\fancyhead[RE,LO]{\textcopyright~ Prints 2019}
\fancyfoot[CE,CO]{}
\fancyfoot[LE,RO]{\thepage}
\everymath{\displaystyle}
\newtheorem{prop}{Proposition}[chapter]
\newtheorem{defn}{Definition}[chapter]
\newtheorem{lemma}{Lemma}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[prop]{Corollary}
\newtheorem{remark}{Remark}
\newtheorem{example}{Example}[chapter]
\newcommand{\floorceil}[1]{\lceil #1 \rfloor}
\makeatletter
\xpatchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}
\makeatother
\renewcommand{\cftpartfont}{\hrule\bfseries\Large}%add line above part
\renewcommand{\cftpartpagefont}{\bfseries}
\setlength{\cftbeforepartskip}{5mm}
\renewcommand{\cftpartafterpnum}{\\\hrule}%add line below part
\cftpagenumbersoff{part}%no page numbers for part-level entries
%% commented out:
%\setlength{\cftsecindent}{8mm}% spacing between number and sec title
%\setlength{\cftsecnumwidth}{6mm}%section indent
%% new instructions:
\cftsetindents{chap}{0em}{1.5em}
\cftsetindents{sec}{1.5em}{2em} % 1st length should be sum of lengths on preceding line
\cftsetindents{subsec}{3.5em}{2.75em}
\setlength{\cftparskip}{4mm}%control line spacing
\begin{document}
\tableofcontents
\part{First part}
\chapter{Chapter1}
\section{Section1.1}
\subsection{Subsection1.1.1}
\chapter{Chapter2}
\section{Section2.1}
\section{Section2.2}
\subsection{Subsection2.2.1}
\part{Second part}
\chapter{Chapter3}
\section{Section3.1}
\subsection{Subsection3.1.1}
\end{document}