我正在使用 book 类制作一本诗集的模板。但是,我注意到在向书中添加章节时遇到了一个主要问题。章节编号全部列为“第 0 章”,尽管有多个章节。我最初认为这可能是由于 \mainmatter 命令放错了位置,但事实似乎并非如此。以下是我的 MWE:
\documentclass[12pt,a4page]{book}
\usepackage{verse}
\usepackage[numberpoems,clearpageafterpoem,useincipits]{poetrytex}
\usepackage{fontspec}
%\setromanfont{Raleway}
\usepackage{rotating,lscape}
\usepackage{tikzpagenodes}
\usepackage{fancyhdr}
\usepackage{incgraph}
\usepackage{multicol}
\usepackage{graphicx}
\setlength{\parindent}{0pt}
\setlength{\stanzaskip}{0.75\baselineskip}
\newcommand{\poemauthorcenter}[1]{\nopagebreak{\footnotesize\textsc{#1}\par}}
\usepackage{indentfirst}
\renewcommand{\poemtitlefont}{\normalfont\itshape\LARGE}
\usepackage{babel}
\usepackage{titletoc}
\setlength{\cftbeforetoctitleskip}{-4em}
\renewcommand{\contentsname}
{Content\\\footnotesize\normalfont\itshape{/kənˈtɛnt/\\$^{1}$In a state of peaceful happiness \\$^{2}$The things that are held or included in something}}%
\renewcommand{\cftaftertoctitle}{\\\rule{\linewidth}{1pt}\vspace*{-5ex}}
\fancyhf{} % clear all header and footers
\renewcommand{\headrulewidth}{0pt} % remove the header rule
\fancyfoot[LE,RO]{\thepage} % Left side on Even pages; Right side on Odd pages
\pagestyle{fancy}
\fancypagestyle{plain}{%
\fancyhf{}%
\renewcommand{\headrulewidth}{0pt}%
\fancyhf[lef,rof]{\thepage}%
}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
\vspace*{10\p@}%
{\parindent \z@ \raggedleft \reset@font
\scshape \@chapapp{} \thechapter
\par\nobreak
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
%\vspace*{1\p@}%
\hrulefill
\par\nobreak
\vskip 10\p@
}}
\usepackage{lipsum}
\renewcommand{\ptdedication}{Here is a \\Dedication}
\begin{document}
\frontmatter
\input{titlepage}
\makededication
\maketoc
\mainmatter
\chapter{Journey}
\lipsum
\chapter{Lorem Ipsum}
\end{document}
编辑:我也尝试使用该\setcounter
命令,但是虽然这会将章节编号从 0 更改为 1,但它会将所有章节重新标记为这样,因此章节编号不会增加。
答案1
\refstepcounter
您的一个软件包禁用了章节编号,大概是故意的,但最简单的更改是在使用计数器之前添加,因此
\def\@makechapterhead#1{%
\vspace*{10\p@}%
{\parindent \z@ \raggedleft \reset@font
\refstepcounter{chapter}%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\scshape \@chapapp{} \thechapter
\par\nobreak
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
%\vspace*{1\p@}%
\hrulefill
\par\nobreak
\vskip 10\p@
}}