3

Sorry if this is an easy question, however I am relatively new to LaTeX and have been trying to understand some of the code in a .cls file.

I'm trying to remove the Chapter from the \chapter headings and in the .cls file there is this code:

\renewcommand{\@makechapterhead}[1]{%
  \vspace*{10\p@}%
  {
    \begin{center}
      \normalfont\heading
      \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter\heading\@chapapp\ \thechapter:\ \fi %\thechapter:\ \fi
      \fi
      \heading #1\par\nobreak
      \vskip 20\p@
    \end{center}
  }
}

I'm not entirely sure what I'm meant to be changing to remove the 'Chapter' part of Chapter 1: Introduction.

Thank you in advance.

2
  • 1
    I would suggest writing in the preamble: \renewcommand\chaptername{\relax}. Or you can use the titlesec package thats allows complete re-formatting chaters, sections and so on.
    – Bernard
    Apr 9, 2014 at 20:54
  • @Bernard Thank you for the tip! That was a quick fix without having to mess with the .cls file
    – Rekovni
    Apr 9, 2014 at 21:03

1 Answer 1

3

The class is non standard, but the code can be easily interpreted: \heading is probably a font selection command defined in the class, whereas \@chapapp is the kernel macro that expands either to \chaptername or to \appendixname, choosing the latter after an \appendix declaration has been processed.

So omitting the fixed word “Chapter” (more precisely, what's contained in the macro \chaptername) is obtained by removing \@chapapp and the space \ after it.

Also the first \heading command is sufficient for setting the font, so it can be omitted in the other places. However, you shouldn't modify the class, but rather put this code in the preamble of your document:

\makeatletter

\renewcommand{\@makechapterhead}[1]{%
  \vspace*{10\p@}%
  {
    \begin{center}
      \normalfont\heading
      \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter\thechapter:\ \fi %\thechapter:\ \fi
      \fi
      #1\par\nobreak
      \vskip 20\p@
    \end{center}
  }
}

\makeatother

If you decide to modify the class, omit \makeatletter and \makeatother (but don't do it this way).

1
  • Thank you for your help! It's made me understand the code a lot better :)
    – Rekovni
    Apr 9, 2014 at 21:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .