# How to have chapter heading style different in chapters with number and chapter without numbers?

I use the following code to change the chapter heading style

\usepackage{titlesec}

\definecolor{RoyalRed}{RGB}{157,16,45}
\titleformat{\chapter}[display]
{\centering\normalfont\bfseries\LARGE}
{\flushright\normalsize\color{RoyalRed}
\MakeUppercase{\chaptertitlename}\hspace{1ex} \thechapter}{1pc}
{{\titlerule[0pt]}\vspace{1pc}\MakeUppercase}


However I would not like to center the heading for chapters with chapter numbers that is when I use \chapter{Chapter1} instead of \chapter*{Abstract}. I want two different heading style dependent on \chapter or \chapter*.

Any help will be great.

• Welcome to TeX.SX! For setting snippets of code, type it, select it and click ont the {} button. For inline code, place it between back quotes as I did in my edit. – egreg Feb 23 '14 at 21:32
• You can define the "numberless" chapter headings with \titleformat{name=\chapter,numberless}... – egreg Feb 23 '14 at 21:33

As suggested by egreg, you can use

\titleformat{name=\chapter,numberless}[display]
{\normalfont\bfseries\LARGE}
{}{1pc}
{{\titlerule[0pt]}\vspace{1pc}\MakeUppercase}


I have added some lines for \titlespacing also. Adjust the values as you like.

Full code:

\documentclass{book}
\usepackage{xcolor,showframe}    %% showframe just for demo
\usepackage{titlesec}

\definecolor{RoyalRed}{RGB}{157,16,45}
\titleformat{\chapter}[display]
{\centering\normalfont\bfseries\LARGE}
{\flushright\normalsize\color{RoyalRed}
\MakeUppercase{\chaptertitlename}\hspace{1ex} \thechapter}{1pc}
{{\titlerule[0pt]}\vspace{1pc}\MakeUppercase}

\titleformat{name=\chapter,numberless}[display]
{\normalfont\bfseries\LARGE}
{}{1pc}
{{\titlerule[0pt]}\vspace{1pc}\MakeUppercase}

\titlespacing*{\chapter}{0pt}{0pt}{*30}                     %% adjust 30 as per need default is 50
\titlespacing*{name=\chapter,numberless}{0pt}{0pt}{*30}     %% adjust 30 as per need

\begin{document}
\chapter{Some chapter with number}
\chapter*{Un-numbered chapter}
\end{document}