2

I need to create a chapter heading that supports a title and a subtitle.

As I see, my distro uses this definition for chapter:

\newcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                \thispagestyle{plain}%
                \global\@topnum\z@
                \@afterindentfalse
                \secdef\@chapter\@schapter}

So, I redefinded \@chapter and \@schapter to meet my needs. My redefinition goes like this:

\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@
}

When I run latex (or pdflatex) with this redefinitions, I got a double heading, first my new defined headings and immediately after, the old one.

What am I doing wrong? Please, help!

  • 2
    welcome to tex.sx. what is the document class where the original definitions are found? – barbara beeton Oct 2 '15 at 17:37
  • 1
    What are you trying to do with the subtitle? Perhaps you only need to modify \novel@makeschapterhead. – John Kormylo Oct 2 '15 at 19:35
  • @barbarabeeton: Looks like ordinary book.cls to me, after modifications, however – user31729 Oct 2 '15 at 20:10
  • I actually am using book.cls. – aBarocio80 Oct 3 '15 at 18:53
  • 1
    Without a minimal working example, nobody can reproduce what is going on. I vote to put on hold as unclear. – Johannes_B May 1 '17 at 11:09

Browse other questions tagged or ask your own question.