# How to format the chapter heading?

How can I change the chapter heading of the book class to typeset centered chapter names as shown in the image above?

-
This depends on how you are writing. What document class are you using? Classes like the KOMA script classes or memoir have their own commands for doing this. Book and report classes will rely on packages like titlesec – Seamus Feb 18 '11 at 17:53

Depends on your level of expertise, if you are more comfortable with packages then using titlesec as suggested by Seamus in the comments is a good choice. If you are here to learn a bit more about the innards of LaTeX you can use the code below, which uses the LaTeX @makechapterhead and @makeschapterhead macros (note the make(s) in the latter). The one is used to handle the normal version of chapter and the other the starred version. It is good practice to update both of them when you are developing or modifying a class. The code can be found in book.cls.

\documentclass[oneside]{book}
\usepackage[english]{babel}
\usepackage{lipsum}
\makeatletter
\def\thickhrule{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\position{\centering}
%% Note the difference between the commands the one is
%% make and the other one is makes
\vspace*{10\p@}%
{\parindent \z@ \position \reset@font
{\Huge \scshape  \thechapter }
\par\nobreak
\vspace*{10\p@}%
\interlinepenalty\@M
\thickhrule
\par\nobreak
\vspace*{2\p@}%
{\Huge \bfseries #1\par\nobreak}
\par\nobreak
\vspace*{2\p@}%
\thickhrule
\vskip 40\p@
\vskip 100\p@
}}

%% This uses makes

\vspace*{10\p@}%
{\parindent \z@ \position \reset@font
{\Huge \scshape \vphantom{\thechapter}}
\par\nobreak
\vspace*{10\p@}%
\interlinepenalty\@M
\thickhrule
\par\nobreak
\vspace*{2\p@}%
{\Huge \bfseries #1\par\nobreak}
\par\nobreak
\vspace*{2\p@}%
\thickhrule
\vskip 100\p@
}}
\begin{document}
\chapter{The Real Numbers}
\lipsum[1-2]
\chapter*{The Imaginary Numbers}
\lipsum[1-2]
\end{document}

-

Here's an example using titlesec.

\documentclass{book}

\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\bfseries\filcenter}
{\LARGE\thechapter}
{1ex}
{\titlerule[2pt]
\vspace{2ex}%
\LARGE}
[\vspace{1ex}%
{\titlerule[2pt]}]

\begin{document}

\chapter{The real numbers}

\end{document}

-

Some example code can be found here: https://slzm.de/blog/schone-kapiteltitelseiten-in-latex/

He uses TikZ to achieve full freedom of positioning the text and drawing stuff around it. The titlesec package is the base it's built on.

The blog has also (similar) examples for redesigning Sections and so forth. Unfortunately all of that is in German, but you can see screenshots and the code is international ;-).

-
Thanks for the link. Nice examples. – Yiannis Lazarides Feb 18 '11 at 18:36
(+1) Liked this too. – chl Feb 18 '11 at 20:57
+1: really nice link – Count Zero Nov 21 '11 at 11:36
The link is no longer available – Ludenticus Feb 13 '15 at 19:03
@Ludenticus The internet link has been updated – loved.by.Jesus Dec 27 '15 at 15:05