![重新定义 \@chapter 和 \@schapter 将使我的标题加倍](https://linux22.com/image/320176/%E9%87%8D%E6%96%B0%E5%AE%9A%E4%B9%89%20%5C%40chapter%20%E5%92%8C%20%5C%40schapter%20%E5%B0%86%E4%BD%BF%E6%88%91%E7%9A%84%E6%A0%87%E9%A2%98%E5%8A%A0%E5%80%8D.png)
我需要创建一个支持标题和副标题的章节标题。
如我所见,我的发行版对章节使用了这个定义:
\newcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter}
因此,我重新定义了\@chapter
并\@schapter
以满足我的需求。我的重新定义如下:
\def\@chapter[#1]#2{
\global\def\chapter@title{#2}
\global\def\chapter@subtitle{#1}
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\chaptername\space\thechapter...}%
\addcontentsline{toc}{chapter}{\main@toc@format}
\else
\refstepcounter{chapter}%
\typeout{\chaptername\space\thechapter.,,}%
\addcontentsline{toc}{chapter}{\preamble@toc@format}
\fi
%\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead]%
\else
\@makechapterhead%
% \@afterheading
\fi
}
\def\@schapter#1{ \global\def\chapter@title{#1}
%\thispagestyle{chapterpage}
\if@twocolumn
\@topnewpage[\@makeschapterhead]%
\else
\@makeschapterhead%
\@afterheading
\fi}
\def\@makechapterhead{%
%\vspace*{20\p@}%
%\thispagestyle{chapterpage}
\begin{center}{\LARGE \bfseries
\if@mainmatter\noindent{
\main@title@format
\ifx\main@subtitle@format\empty
\else
\\\vspace{2ex}
\Large\noindent
\main@subtitle@format
\fi}
\else
\preamble@title@format
\fi
}\end{center}\par\nobreak
\vskip 20\p@
\typeout{Ended heading of \chaptername\space\thechapter!}
}
\def\@makeschapterhead{%
%\vspace*{20\p@}%
\begin{center}{\LARGE \bfseries\preamble@title@format}\par\nobreak
\ifx\preamble@subtitle@format\empty
\else
\\\vspace{2ex}
\Large\bfseries\noindent
\preamble@subtitle@format
\fi
\end{center}\par\nobreak
\vskip 20\p@
}
当我运行latex
(或pdflatex
)这些重新定义时,我得到了双重标题,首先是我新定义的标题,紧接着是旧标题。
我做错了什么?请帮忙!