我在章节本身和目录中使用了不同的章节名称: 。我还按照以下说明在章节标题中\chapter[Chapter 1 – Introduction]{Introduction}
使用章节编号 ( )。\thechapter
此建议。
似乎存在冲突,\setcounter{secnumdepth}{0}
因为目录仍然添加了额外的章节编号:
我怎样才能去掉那些多余的章节编号(例如1第 1 章 – 简介)?
我开始使用大量自定义代码。代码如下(抱歉,软件包列表很长):
\documentclass[12pt,openany,hidelinks]{book}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage[left=1in,right=1in,top=1in,bottom=1.2in]{geometry}
\usepackage{import}
\usepackage{setspace}
\setstretch{1.15}
\usepackage{afterpage}
\usepackage{xcolor}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{tabularx,graphicx}
\usepackage{imakeidx}
\usepackage{textcomp}
\usepackage{multicol}
\usepackage{multirow}
\usepackage[labelformat=empty]{caption}
\usepackage{array}
\usepackage{makecell}
\usepackage{etoolbox}
\usepackage{float}
\usepackage{hyperref}
\usepackage{changepage}
\urlstyle{rm}
\usepackage{fancyhdr}
\usepackage{url}
\usepackage{xurl}
\graphicspath{ {./images/} }
\indexsetup{othercode=\small}
\makeindex[program=makeindex,columns=2,intoc=false,options={-s index-style.ist}]
\usepackage{enumitem,amssymb}
\usepackage{titlesec}
\usepackage{totcount}
\usepackage{tocloft}
% Chapter Headers
\regtotcounter{chapter}
\titleformat{\chapter}[hang]
{\raggedright\rmfamily\bfseries\fontsize{62}{56}\selectfont}
{\LARGE\rmfamily\mdseries
% magic number 25pt
\raisebox{25pt}{\smash{\parbox[t]{4em}{\thechapter\\/\\26}}}}
{0pt}{}
\titlespacing*{\chapter}{0pt}{50pt}{40pt}[140pt]
% Title Sizes
\titlespacing*{\chapter}{0pt}{0pt}{140pt} % Redundant but needed
\titleformat{\section}[display]
{\huge\bfseries}{}{0pt}{\fontsize{22}{24}\selectfont}
\titlespacing*{\section}{0pt}{17pt}{20pt}
\titleformat{\subsection}[display]
{\huge\bfseries}{}{0pt}{\fontsize{22}{28}\selectfont}
\titlespacing*{\subsection}{0pt}{20pt}{20pt}
% Table of Contents Config
\newcount\cnta
\cftsetpnumwidth{0pt}
\renewcommand\cftsecpagefont {\ttfamily\global\cnta}
\renewcommand\cftsecafterpnum {%
\makebox[0pt][l]%
{\kern-\dimexpr\linewidth\relax\makebox[2em][l]{\ttfamily\normalsize\the\cnta}}%
}
\renewcommand{\cftpartpagefont}{\ttfamily\global\cnta}
\renewcommand\cftpartafterpnum {%
\makebox[0pt][l]%
{\kern-\dimexpr\linewidth\relax\makebox[2em][l]{\ttfamily\large\the\cnta}}%
\vskip14pt
}
\renewcommand{\cftchappagefont}{\ttfamily\bfseries\global\cnta}
\renewcommand\cftchapafterpnum {%
\makebox[0pt][l]%
{\kern-\dimexpr\linewidth\relax\makebox[2em][l]{\large\bfseries\the\cnta}}%
\vskip7pt
}
\renewcommand{\cftdot}{}
\setcounter{tocdepth}{1}
\setcounter{secnumdepth}{0}
\renewcommand{\contentsname}{Table of Contents}
\renewcommand{\cftpartfont}{\ttfamily\large}
\renewcommand{\cftchapfont}{\rmfamily\large\bfseries}
\setlength{\cftpartindent}{4em}
\setlength{\cftchapindent}{4em}
\setlength{\cftsecindent}{4em}
\begin{document}
% Table of Contents
\tableofcontents{}
\addcontentsline{toc}{part}{Inception}
\chapter[Chapter 1 – Introduction]{Introduction}
\section{Section A}
\section{Section B}
\section{Section C}
\chapter[Chapter 2 – Middle]{Middle}
\section{Section A}
\section{Section B}
\section{Section C}
\chapter[Chapter 3 – Middle]{Conclusion}
\section{Section A}
\section{Section B}
\section{Section C}
\end{document}
答案1
更改\ctfchapfont
来自的重新定义
\renewcommand{\cftchapfont}{\rmfamily\large\bfseries}
到
\renewcommand{\cftchapfont}{\rmfamily\large\bfseries\renewcommand\numberline[1]{}}
这意味着,(本地)重新定义\numberline
每个章节的目录条目,因此章节编号在排版中是隐藏的。
\documentclass[12pt,openany]{book}
\usepackage[left=1in,right=1in,top=1in,bottom=1.2in]{geometry}
\usepackage{titlesec}
\usepackage{totcount}
\usepackage{tocloft}
% Chapter Headers
\regtotcounter{chapter}
\titleformat{\chapter}[hang]
{\raggedright\rmfamily\bfseries\fontsize{62}{56}\selectfont}
{\LARGE\rmfamily\mdseries
% magic number 25pt
\raisebox{25pt}{\smash{\parbox[t]{4em}{\thechapter\\/\\26}}}}
{0pt}{}
\titlespacing*{\chapter}{0pt}{50pt}{40pt}[140pt]
% Title Sizes
\titlespacing*{\chapter}{0pt}{0pt}{140pt} % Redundant but needed
\titleformat{\section}[display]
{\huge\bfseries}{}{0pt}{\fontsize{22}{24}\selectfont}
\titlespacing*{\section}{0pt}{17pt}{20pt}
\titleformat{\subsection}[display]
{\huge\bfseries}{}{0pt}{\fontsize{22}{28}\selectfont}
\titlespacing*{\subsection}{0pt}{20pt}{20pt}
% Table of Contents Config
\newcount\cnta
\cftsetpnumwidth{0pt}
\renewcommand\cftsecpagefont {\ttfamily\global\cnta}
\renewcommand\cftsecafterpnum {%
\makebox[0pt][l]%
{\kern-\dimexpr\linewidth\relax\makebox[2em][l]{\ttfamily\normalsize\the\cnta}}%
}
\renewcommand{\cftpartpagefont}{\ttfamily\global\cnta}
\renewcommand\cftpartafterpnum {%
\makebox[0pt][l]%
{\kern-\dimexpr\linewidth\relax\makebox[2em][l]{\ttfamily\large\the\cnta}}%
\vskip14pt
}
\renewcommand{\cftchappagefont}{\ttfamily\bfseries\global\cnta}
\renewcommand\cftchapafterpnum {%
\makebox[0pt][l]%
{\kern-\dimexpr\linewidth\relax\makebox[2em][l]{\large\bfseries\the\cnta}}%
\vskip7pt
}
\renewcommand{\cftdot}{}
\setcounter{tocdepth}{1}
\setcounter{secnumdepth}{0}
\renewcommand{\contentsname}{Table of Contents}
\renewcommand{\cftpartfont}{\ttfamily\large}
\renewcommand{\cftchapfont}{\rmfamily\large\bfseries\renewcommand\numberline[1]{}}
\setlength{\cftpartindent}{4em}
\setlength{\cftchapindent}{4em}
\setlength{\cftsecindent}{4em}
\begin{document}
% Table of Contents
\tableofcontents
\addcontentsline{toc}{part}{Inception}
\chapter[Chapter 1 – Introduction]{Introduction}
\section{Section A}
\section{Section B}
\section{Section C}
\chapter[Chapter 2 – Middle]{Middle}
\section{Section A}
\section{Section B}
\section{Section C}
\chapter[Chapter 3 – Middle]{Conclusion}
\section{Section A}
\section{Section B}
\section{Section C}
\end{document}
答案2
您正在自己将**第 1 章 - **添加到目录中。
此\chapter
宏接受一个可选参数和一个必需参数。这些参数包括:
\chapter[
目录+页眉标题]{
标题}
所以你的\chapter[Chapter 1 - Introduction]{Introduction}
看跌期权第 1 章 - 简介放入目录和页眉,加上章节号并放入第1章紧接着另一行介绍在文档正文中。
因此,不要使用可选参数。
但是,如果您需要目录、标题和文档中的不同条目,则该类memoir
(的超集)为和其他部门标题book
提供了两个可选参数,如下所示:\chapter
\chapter[
目录标题][
标题]{
标题}