5

I want each numberless "chapter" page to have a different style for the title. Please see:

\documentclass{book}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\Large\filcenter\sffamily}
{\titlerule[1pt]%
\vspace{1pt}%
\titlerule
\vspace{1pc}%
\LARGE\MakeUppercase{\chaptertitlename} \thechapter}
{1pc}
{\titlerule
\vspace{1pc}%
\Huge}


\titleformat{name=\chapter,numberless}[display]
{\normalfont\Large\filcenter\sffamily}
{\titlerule[1pt]%
\vspace{1pt}%
\titlerule
\vspace{1pc}%
\LARGE{something for index only}}
{1pc}
{\titlerule
\vspace{1pc}%
\Huge}

\begin{document}
\tableofcontents
\chapter{My first chapter}
dummy text

\chapter{My second chapter}
ciao
\end{document}

With the previous code I have:

  1. a title style for normal chapter pages
  2. a title style for all numberless chapter pages: index page, bibliography page, etc.

I want to have multiple numberless styles, one for the index page, one for the bibliography page, etc. How do I add more than two styles?

Lupen
  • 179
  • You can give \titleformat{name=\chapter,numberless}... anywhere and at any time; the current style will be used for the next \chapter* commands until a new declaration is issued. But why should you do it? – egreg Sep 21 '14 at 21:46
  • @egreg In my style (the one posted was a random one taken from the titlesec documentation), I have some space which is filled with the number in case of the numbered chapters and is empty for index and bibliography. I want to place a symbol for the index (like a dotted list) and another one for the bibliography (like a book). Anyway, it works. Thanks. – Lupen Sep 21 '14 at 21:54

1 Answers1

7

You can place \titleformat instructions anywhere and the format declaration will hold for all subsequent chapters, until a new \titleformat instruction comes along.

Probably the best is to define all formats in the preamble, hiding them in macros. For instance

\newcommand{\tocformat}{%
  \titleformat{name=\chapter,numberless}[display]
    {\normalfont\Large\filcenter\sffamily}
    {\titlerule[1pt]%
     \vspace{1pt}%
     \titlerule
     \vspace{1pc}%
     \LARGE something for TOC only}%%%% <---- \LARGE doesn't take an argument
    {1pc}
    {\titlerule
     \vspace{1pc}%
     \Huge}%
}

\newcommand{\bibliographyformat}{%
  \titleformat{name=\chapter,numberless}[display]
    {\normalfont\Large\filcenter\sffamily}
    {\titlerule[1pt]%
     \vspace{1pt}%
     \titlerule
     \vspace{1pc}%
     \LARGE something for bibliography only}
    {1pc}
    {\titlerule
     \vspace{1pc}%
     \Huge}%
}

and issue \tocformat and \bibliographyformat in the document at the appropriate spots. This way you have a “centralized” place for all document setup.

The styling could be also automatized by incorporating the \...format commands in the relevant commands such as \tableofcontents via \pretocmd of etoolbox or similar patching macros.

egreg
  • 1,121,712