How to Center Selected Chapter Headings in LaTeX
At a glance
- 1. Load sectsty
Add the sectsty package to your preamble.
- 2. Group the change
Locally set the chapter heading style to centered inside a group.
- 3. Create the chapter
Issue the chapter command before ending the group; later chapters keep their usual alignment.
The sectsty package can change the appearance of chapter headings. To center only selected chapters, make the alignment change local: group the \chapterfont{\centering} setting together with the \chapter command. When the group ends, the heading style returns to its previous setting.
Center one chapter
Load sectsty in the preamble, then wrap the chapter command in a group:
\documentclass{book}
\usepackage{sectsty}
\begin{document}
\chapter{A Regular Chapter}
This chapter uses the document's usual heading style.
\begingroup
\chapterfont{\centering}
\chapter{A Centered Chapter}
\endgroup
\chapter{Another Regular Chapter}
This chapter returns to the usual heading style.
\end{document}
The key is that both the style change and the chapter command occur before \endgroup. The setting applies while LaTeX constructs that heading; it does not affect the later chapter. Use another such group around each chapter you want centered.
Center every chapter
If you want all chapter headings centered, put the setting in the preamble instead of using a group around individual chapters:
\documentclass{book}
\usepackage{sectsty}
\chapterfont{\centering}
\begin{document}
\chapter{First Chapter}
\chapter{Second Chapter}
\end{document}
The preamble setting applies throughout the document. The grouped version is the useful one when most chapters should retain the class’s normal alignment.
What the grouping changes
A group limits the scope of LaTeX settings made inside it. Here, the group makes the alignment change temporary. The chapter heading is produced by \chapter, so put that command inside the group rather than grouping only the \chapterfont setting and ending the group before the heading is made.
The \centering declaration centers the heading contents, including the chapter number when it is part of the heading. It is a declaration, not a command that takes the title as an argument.
Common mistakes
- Setting the style globally by accident: A preamble declaration such as
\chapterfont{\centering}centers all chapter headings. Use a group around just the chosen chapter for selective formatting. - Ending the group too early: If
\endgroupcomes before\chapter, the chapter heading is made after the local setting has ended. - Using a class without chapters: The standard
articleclass has no\chaptercommand. Use a chapter-based class such asbookorreport, or choose a sectioning command that exists in your class. - Expecting body text to be centered: This setting is for the chapter heading, not the paragraphs that follow it.
- Mixing heading packages without checking compatibility: If you already use another package that customizes chapter titles, avoid applying multiple competing heading-format systems. Follow that package’s method for making a one-off style change.
Centering with other chapter styles
If you have customized chapter fonts with sectsty, keep those desired font commands when changing the alignment. For example, a style can combine centering with bold type: \chapterfont{\centering\bfseries}. The exact font size and weight depend on your document class and existing settings. Check a compiled page to ensure the chapter number and title have the appearance you intend.
A starred heading such as \chapter*{Preface} can also be placed inside the group when it should be centered. Starred chapters are unnumbered; adding them to the table of contents, if desired, is a separate task.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.