4

I want my chapter titles to look as they would with the code below.

\documentclass[12pt]{book}
\pagestyle{plain}
\usepackage{amssymb,latexsym}
\usepackage{amsmath}
\usepackage{amsthm}
\begin{document}
\centering
 CHAPTER II \\
 SUBSQUARES

\end{document}

Centered all caps and with roman numeral numbering. I have tried titlesec and \renewcommand. Apparently, I do not understand the parameters of \titleformat well enough to get it to do what I want. I can get something close with \renewcommand however the chapter numbers do not increment. Any help is very appreciated.

\renewcommand{\chapter}{\uppercase{CHAPTER} {\Roman{chapter}}  \\}
  • Look at the sectsty package, or look on this site for examples of titlesec usage. Since you are using the book class, you might consider switching to memoir, which provides its own interface for adjusting the headings (or a KOMA class for the same reason). There is too much built-in code (for spacing, font, counters, etc.) in the original definition of the section headings to alter them simply with a \renewcommand. – musarithmia Jan 20 '15 at 19:08
  • Do you want the same (centering + CAPITAL LETTERS) for \section? What about \subsection...? – Werner Jan 20 '15 at 19:48
6

I think that using the sectsty package is simpler.

Just add the following lines to your preamble

\usepackage{sectsty}

\renewcommand{\thechapter}{\Roman{chapter}}
\chapterfont{\centering\MakeUppercase}

MWE

\documentclass[12pt]{book}
\pagestyle{plain}
\usepackage{amssymb,latexsym}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{sectsty}

\renewcommand{\thechapter}{\Roman{chapter}}
\chapterfont{\centering\MakeUppercase}

\begin{document}

\chapter*{Unnumbered Chapter}

\chapter{Numbered Chapter}

\appendix

\chapter{An Appendix}

\end{document} 

Output

enter image description here

3

Here is a crude way of implementing your requirement. It uses etoolbox to patch the macros responsible for creating the chapter headings. There are two macros, one for \chapter and one for \chapter*. In each of these macros, an adjustment is made to the chapter title (argument #1) as well as the horizontal alignment - changing from \raggedright to \centering. As such, a total of 4 patches are made.

enter image description here

\documentclass{book}
\usepackage{etoolbox}

\makeatletter
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\@chapapp}{\MakeUppercase{Chapter}}
% \patchcmd{<cmd>}{<search>}{<replace>}{<succes>}{<failure>}
\patchcmd{\@makechapterhead}{#1}{\MakeUppercase{#1}}{}{}
\patchcmd{\@makechapterhead}{\raggedright}{\centering}{}{}
\patchcmd{\@makeschapterhead}{#1}{\MakeUppercase{#1}}{}{}
\patchcmd{\@makeschapterhead}{\raggedright}{\centering}{}{}
\makeatother

\begin{document}

\chapter*{First chapter}

\chapter{Second chapter}

\end{document}

The other changes to \thechapter sets the output to print a \Roman format of the chapter counter, while an adjustment to \@chappapp sets the Chapter prefix in CAPITAL LETTERS. This may need some minor adjustments if you also have an Appendix chapter.

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.