9

In the MWE below. What is the most convenient way to center the titles Preface and Abstract, rather than setting them flush left?

\documentclass{book}
\begin{document}

\chapter*{Preface}
\chapter*{Abstract}

\chapter{Introduction}
\chapter{Body}
\chapter{Conclusion}

\end{document}
  • Have a look to the titlesec package. – GuM May 25 '15 at 8:20
  • 1
    You are talking of centering the titles horizontally, not both horizontally and vertically? – user31729 May 25 '15 at 8:41
  • 2
    Should centering be applied only to unnumbered chapter headings, or to all chapter headings? – Mico May 25 '15 at 8:44
12

Since this about the \chapter* command for two titles (Abstract and Preface) only, it's sufficient to say \chapter*{\centering Abstract} etc. as command. This is grouped inside the internal command \@makeschapterhead -- it does not have a side effect on other implicitly used \chapter* commands, such as in \tableofcontents.

(The \blindtext as well as Some text aren't centered, so the \centering inside the \chapter* argument is safe, as long as no entry to the ToC is necessary (which is not the case, as we are talking about \chapter*)

If all \chapter* or \chapter titles should be centered horizontally, an \xpatchcmd approach is more useful. (See the edit at the bottom of this answer)

\documentclass{book}



\usepackage{blindtext}

\begin{document}

\chapter*{\centering Preface}
\blindtext

Some text
\chapter*{\centering Abstract}


\chapter{Introduction}
\chapter{Body}
\chapter{Conclusion}

\end{document}

enter image description here

Edit

This code centers all chapter titles (regardless whether \chapter* or \chapter) horizontally

\documentclass{book}

\usepackage{xpatch}
\usepackage{blindtext}


\makeatletter

\xpatchcmd{\@makeschapterhead}{%
  \Huge \bfseries  #1\par\nobreak%
}{%
  \Huge \bfseries\centering #1\par\nobreak%
}{\typeout{Patched makeschapterhead}}{\typeout{patching of @makeschapterhead failed}}


\xpatchcmd{\@makechapterhead}{%
  \huge\bfseries \@chapapp\space \thechapter
}{%
  \huge\bfseries\centering \@chapapp\space \thechapter
}{\typeout{Patched @makechapterhead}}{\typeout{Patching of @makechapterhead failed}}

\makeatother

\begin{document}
\tableofcontents

\chapter*{Preface}
\blindtext

Some text
\chapter*{Abstract}
\blindtext


\chapter{Introduction}
\blindtext

Another text


\chapter{Body}
\blindtext

\chapter{Conclusion}
\blindtext


\end{document}

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.