0

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

enter image description here

The output I tried to do is as follows. But I can't. How will my code change?

enter image description here

EDIT: @Sveinung's output on my computer

enter image description here

5
  • \chapter{Index} instead of \chapter*{Index}works for me.
    – user31034
    Commented Aug 24, 2019 at 9:44
  • Since you have chosen unnumbered Index by using the starred version of \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 the chapter- command.
    – Sveinung
    Commented Aug 24, 2019 at 9:46
  • @ferahfeza, indexed words typed on a new page.
    – Özgür
    Commented Aug 24, 2019 at 9:57
  • @Sveinung, I'll try.
    – Özgür
    Commented Aug 24, 2019 at 9:57
  • Yes. I think you have solved.
    – Özgür
    Commented Aug 24, 2019 at 10:51

1 Answer 1

1

Using imakeidx package, and from this nice answer, I found the following solution.

\documentclass[]{book}
\usepackage{xpatch}
\usepackage[explicit]{titlesec}
%%%%%%%%% New code block %%%%%%%%
\usepackage{imakeidx}
\indexsetup{level=\chapter} 
\makeindex[columns=1]
\makeatletter
\xpatchcmd{\imki@putindex}
{\immediate}
{\ifimki@disableautomatic\else\immediate}
{}{}
\xpatchcmd{\imki@putindex}
{\endcsname}
{\endcsname\fi}
{}{}
\makeatother
%%%%%%%%% End of New code block %%%%%%%%

\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} %<-- No need 
\printindex
\chapter{Foo}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .