1

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

\documentclass[12pt,oneside]{book}

% packages
\usepackage{amssymb, amsmath, amsthm}
\usepackage{graphicx}
\usepackage{apacite}
\usepackage[round]{natbib}
\usepackage{sectsty}
\usepackage{graphicx,pstricks}
\usepackage{graphics}
\usepackage{moreverb}
\usepackage{subfigure}
\usepackage{epsfig}
\usepackage{subfigure}
\usepackage{txfonts}
\usepackage{palatino}
\usepackage{blindtext}
\usepackage{xpatch}

% these make top, right, bottom margins about 1"
% and the left margin about 1.5"
\setlength{\textwidth}{5.75in}
\setlength{\oddsidemargin}{0.5in}
\setlength{\evensidemargin}{0.0in}
\setlength{\textheight}{9.0in}
\setlength{\topmargin}{0.0in}



% this makes the chapters start with a 2" margin


\makeatletter
\renewcommand*\@makechapterhead[1]{%
  \vspace*{0.75in}%
  {\parindent \z@ \raggedright \normalfont 
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@

  }}
\renewcommand*\@makeschapterhead[1]{%
  \vspace*{0.75in}%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 40\p@

  }}
\makeatother



% makes page numbers appear
\pagestyle{plain} 

\renewcommand*\contentsname{Table of Contents}


\begin{document} 
5
  • 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
1

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

\documentclass{memoir}
\chapterstyle{bianchi} 
% try also "chappell", "dash", "demo2", "dowding" and "thatcher"
\begin{document}
\chapter{My chapter}
\end{document}

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.

\documentclass{book}
\usepackage[Rejne]{fncychap} 
\ChTitleAsIs
\ChNameAsIs
\ChRuleWidth{0pt}
\begin{document}
\chapter{My chapter}
\end{document}

Or you can use the sectsty package:

\documentclass{book}
\usepackage{sectsty}\chapterfont{\centering}
\begin{document}
\chapter{My chapter}
\end{document}

Or the anonchap package;

\documentclass{book}
\usepackage{anonchap}
\simplechapter[\centering Chapter]
\renewcommand{\simplechapterdelim}{\par}
\begin{document}
\chapter{My chapter}
\end{document}

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.