我需要创建一个支持标题和副标题的章节标题。
如我所见,我的发行版对章节使用了这个定义:
\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
)这些重新定义时,我得到了双重标题,首先是我新定义的标题,紧接着是旧标题。
我做错了什么?请帮忙!