Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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 at 21:32
    
You can define the "numberless" chapter headings with \titleformat{name=\chapter,numberless}... –  egreg Feb 23 at 21:33

1 Answer 1

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}

enter image description here

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.