I have a multipart book. I want to create different styles for different chapters. Based on this, I worked so far:
\documentclass[10pt]{book}
\usepackage{titlesec}
%original definition Style A
\titleformat{\chapter}[display]
{\normalfont\bfseries\filcenter}{\LARGE\thechapter}{1ex}
{\titlerule[2pt]\vspace{2ex}}[\vspace{1ex}{\titlerule[2pt]}]
\titleformat{name=\chapter,numberless}[display]
{\normalfont\LARGE\bfseries\filcenter}{}{1ex}
{\vspace{2ex}}[\vspace{1ex}]
%end of original definition
\begin{document}
\part{First Part}
THis
\chapter{Chapter one}
\chapter{Chapter two}
%another definition Style B
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\filcenter\underline{\MakeUppercase{{\chaptertitlename}}\ \thechapter}}{20pt}{\Huge}
%end of other definition
\part{Second Part}
\chapter{Chapter three}
\chapter{Chapter four}
\titleformat{\chapter}[display]
{\normalfont\bfseries\filcenter}{\LARGE\thechapter}{1ex}
{\titlerule[2pt]\vspace{2ex}}[\vspace{1ex}{\titlerule[2pt]}]
\chapter{Chapter five}
\end{document}
Problem is: Every time I have to set definition for new styles. My chapters will switch within frequently: Style A, Style B, Back to Style A, Style B, Even Style C (not implemented in code), Style A, Style B etc.
You see in code definition Style A is working on two chapters in Part 1, then definition Style B is applied on next two chapters, again next chapters uses definition Style A.
Is there any way to make this more organized that I can easily switch between styles for the chapters?
Best Answer
Define two commands
\chapterA
to apply to chapters style A and a\chapterB
for style B.