I can't seem to find a way to center all of my chapters (both Chapter X, and the title of the chapter) without altering table of contents or causing errors rending the code unable to run


% packages
\usepackage{amssymb, amsmath, amsthm}

% these make top, right, bottom margins about 1"
% and the left margin about 1.5"

% this makes the chapters start with a 2" margin

  {\parindent \z@ \raggedright \normalfont 
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries \@chapapp\space \thechapter
        \vskip 20\p@
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@

  {\parindent \z@ \raggedright
    \Huge \bfseries  #1\par\nobreak
    \vskip 40\p@


% makes page numbers appear

\renewcommand*\contentsname{Table of Contents}

  • 2
    s/raggedright/centering/ in your redefinitions of your chapterhead. And welcome, by the way. – Johannes_B Sep 17 '17 at 14:49
  • 3
    If you copied the code from somewhere without knowing what it does, you will get into more trouble. LaTeX for complete novices (<- Link to free ebook) is a good read to start with. – Johannes_B Sep 17 '17 at 14:50
  • You could have a look at the following answers: tex.stackexchange.com/a/23859/134144 tex.stackexchange.com/a/107282/134144 – leandriis Sep 17 '17 at 14:53
  • @Johannes_B: Not everyone is aware about the /s/foo/bar syntax... – user31729 Sep 17 '17 at 15:52
  • Also, \@makechapterhead is for numbered chapters and \@makeschapterhead is for unnumbered chapters (like Table of Contents). – John Kormylo Sep 17 '17 at 16:27

An easy way is use the memoir class and one already made chapter style:

% try also "chappell", "dash", "demo2", "dowding" and "thatcher"
\chapter{My chapter}

You can also \makechapterstyle if none of these is good for you. Run texdoc memoir for more information.

There also a centered "Rejne" style in fncychap package. There are some commands for some customization. Run texdoc fncychap for more information.

\chapter{My chapter}

Or you can use the sectsty package:

\chapter{My chapter}

Or the anonchap package;

\simplechapter[\centering Chapter]
\chapter{My chapter}

Or the titlesec package as explained in Center aligning chapters.

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.