20

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

  • 2
    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
26

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.

enter image description here

\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
\renewcommand{\@makechapterhead}[1]{%
  \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

\def\@makeschapterhead#1{%
  \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}
20

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}
10

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 ;-).

  • 5
    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
  • 3
    The link is no longer available. – B. Pasternak Jun 7 '16 at 9:49
  • 1
    This isn't an answer, and the link (the only real content provided) doesn't work :( – Jonathan W. Jul 15 '16 at 21:48
  • Link doesn't work – baxx Sep 20 '18 at 20:26

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.