I want to left or right align my chapter number, and center the chapter title on the next page. I've used the \titlesec
package, but it removes the header and footer on the first page of every chapter. The code I've written right aligns both the chapter number and the title. Is there any workaround?
\documentclass{report}
\usepackage{fancyhdr}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\Large\bfseries\raggedleft}{\chaptertitlename\ \thechapter}
{20pt}{\Large}
\pagestyle{fancy}
\rhead{XYZ}
\lhead{year}
\lfoot{Blah}
\cfoot{}
\rfoot{\thepage}
\begin{document}
\chapter{Title}
Test
\end{document}
Best Answer
To have the header/footer in the first page of every chapter, you can patch (with the help of, for example,
etoolbox
package) the\chapter
command to change the defaultplain
style forfancy
.To have the chapter name+chapter number right (left aligned) you can use
\filright
(\filleft
, respectively) in the second argument for\titleformat
and then\filcenter
in the fifth argument to have the title centered;I used the
geometry
package with itsshowframe
option just to have a visual guideline.