Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
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

3 Answers 3

up vote 19 down vote accepted

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}
share|improve this answer

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}
share|improve this answer

Some example code can be found here: http://web.slzm.de/blog/latex/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 ;-).

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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