17

I am using report document class. I want to remove word "Chapter" and "chapter number" from chapter title, so when new chapter starts I will get only chapter title. I can do it using:

\renewcommand{\chaptername}{}
\renewcommand{\thechapter}{}

It looks ok, but it breaks the table of contents. I want numbered chapters on table of contents, e.g.

  1. Function name one

1.1 Parameters

1.2 Returned value

but the table of contents looks like this:

Function name one

.1 Parameters

.2 Returned value

I know I can do it using the package titlesec, but is there a way to do it without it?

15

You can redefine the internal way of the chapter output:

\makeatletter
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    %\ifnum \c@secnumdepth >\m@ne
    %    \huge\bfseries \@chapapp\space \thechapter
    %    \par\nobreak
    %    \vskip 20\p@
    %\fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
  \makeatother
15

Basically you will want to renew the command that deals with the chapter title formatting. This link explains it pretty well. Since you don't want the starred version, you can settle with changing the normal version.

\renewcommand{\@makechapterhead}[1]{%
 \vspace*{50\p@}%
 {\parindent \z@ \raggedright \normalfont
  \hrule                                        % horizontal line
  \vspace{5pt}%                                 % add vertical space
  \ifnum \c@secnumdepth >\m@ne
   \huge\scshape \@chapapp\space \thechapter    % Chapter number
   \par\nobreak
   \vskip 20\p@
  \fi
  \interlinepenalty\@M
  \Huge \scshape #1\par                         % chapter title
  \vspace{5pt}%                                 % add vertical space
  \hrule                                        % horizontal rule
  \nobreak
  \vskip 40\p@
 }%
}

What you will want to do is comment out the line that has the Chapter number comment and the surrounding comments (everything inside of the if) to get rid of the extra space. You can customize this command a little further if you want to change the looks of the chapter headings. Take note that you have to wrap this in \makeatletter and \makeatother to change the catcode for the @ symbol. So you would get:

\makeatletter
\renewcommand{\@makechapterhead}[1]{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
  \hrule                                        % horizontal line
  \vspace{5pt}%                                 % add vertical space
  \interlinepenalty\@M
  \Huge \scshape #1\par                         % chapter title
  \vspace{5pt}%                                 % add vertical space
  \hrule                                        % horizontal rule
  \nobreak
  \vskip 40\p@
  }%
}
\makeatother

And a simple test document

\documentclass{report}
\begin{document}
\makeatletter
\renewcommand{\@makechapterhead}[1]{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
  \hrule                                        % horizontal line
  \vspace{5pt}%                                 % add vertical space
  \interlinepenalty\@M
  \Huge \scshape #1\par                         % chapter title
  \vspace{5pt}%                                 % add vertical space
  \hrule                                        % horizontal rule
  \nobreak
  \vskip 40\p@
  }%
}
\makeatother
\tableofcontents
\chapter{Test}
 some test text
\end{document}

Would look like this:

toc chapter caption

edit: too slow :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.