MWE
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{makeidx}
\makeindex
\usepackage{tikz}
\newcommand{\chaptercolor}{blue}
\titleformat{\chapter}
[display]
{\normalfont\filcenter}
{\tikz[remember picture,overlay]
{\node[fill=\chaptercolor,%<--- Not hardcoded color
font=\sffamily\fontsize{96}{72}\bf\selectfont\color{white},anchor=north east,
minimum width=3cm,
minimum height=3.4cm]
at ([xshift=-1cm,yshift=-1cm]current page.north east)
(numb) {\thechapter};
\node[rotate=90,
anchor=south,
inner sep=4pt,
font=\Huge\itshape]
at (numb.west) {\chaptertitlename};%<-- Not hardcoded "CHAPTER"
}}
{20pt}
{\raggedright\Huge\bfseries\itshape\color{\chaptercolor}#1}%< Not hardcoded color
[\vskip10pt\Large\bfseries]
\begin{document}
\chapter{Preface}
\index{one}\index{two}\index{ten}
\appendix
\chapter*{Index}
\printindex
\end{document}
Output
The output I tried to do is as follows. But I can't. How will my code change?
EDIT: @Sveinung's output on my computer
\chapter{Index}
instead of\chapter*{Index}
works for me.\chapter
, you will of cause not get the blue box with the number. If you really want a blue, empty box beside the word Index, you have to redefine also the starred version of thechapter
- command.