1

In the code below, I wanted to be able to get "Index" to show up in the header and also the Chapter Thumb in the Index section of the document.

\documentclass{book}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{newtxtext,newtxmath}
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagestyle{plain}
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\newcommand\BoxColor{ocre!60}
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}

\usepackage{etoolbox,fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}}
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage}
\fancyhead[LO]{\rightmark%
\begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north east]
  at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\scshape\leftmark}}}};
  \end{tikzpicture}}
\fancyhead[RE]{\leftmark%
  \begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north west]
  at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\scshape\leftmark}}}};
  \end{tikzpicture}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\newcommand{\headrulecolor}[1]{\patchcmd{\headrule}{\hrule}{\color{#1}\hrule}{}{}}
\headrulecolor{blue!70}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}

\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
\patchcmd{\@makechapterhead}
  {\vskip 40\p@}
  {\vskip 40\p@\stepcounter{chapshift}}{}{}
\makeatother

\usepackage{imakeidx}
\makeindex

\begin{document}
\mainmatter
\chapter{Chapter 1}
\lipsum
This is an example of how the index appears\index{appears}

\appendix
\chapter{Appendix 1}
\lipsum

\cleardoublepage
\setlength{\columnsep}{0.75cm}
\addcontentsline{toc}{chapter}{\textcolor{ocre}{Index}}

\renewcommand\chaptermark[1]{\markboth{\sffamily\normalsize\bfseries\indexname}{}}
\printindex
\lipsum

\end{document} 
3
  • replace \renewcommand\chaptermark[1]{\markboth{\sffamily\normalsize\bfseries\indexname}{}} by \markboth{\sffamily\normalsize\bfseries\indexname}{}
    – touhami
    Aug 31, 2015 at 21:11
  • @touhami Please write an answer. Aug 31, 2015 at 22:30
  • @GonzaloMedina done.
    – touhami
    Aug 31, 2015 at 23:03

1 Answer 1

3

All what you need here is to replace

\renewcommand\chaptermark[1]{\markboth{\sffamily\normalsize\bfseries\indexname}{}}

with

\markboth{\sffamily\normalsize\bfseries\indexname}{}

complete code

\documentclass{book}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{newtxtext,newtxmath}
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagestyle{plain}
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\newcommand\BoxColor{ocre!60}
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}

\usepackage{etoolbox,fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}}
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage}
\fancyhead[LO]{\rightmark%
\begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north east]
  at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\scshape\leftmark}}}};
  \end{tikzpicture}}
\fancyhead[RE]{\leftmark%
  \begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north west]
  at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\scshape\leftmark}}}};
  \end{tikzpicture}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\newcommand{\headrulecolor}[1]{\patchcmd{\headrule}{\hrule}{\color{#1}\hrule}{}{}}
\headrulecolor{blue!70}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}

\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
\patchcmd{\@makechapterhead}
  {\vskip 40\p@}
  {\vskip 40\p@\stepcounter{chapshift}}{}{}
\makeatother

\usepackage{imakeidx}
\makeindex

\begin{document}
\mainmatter
\chapter{Chapter 1}
\lipsum
This is an example of how the index appears\index{appears}

\appendix
\chapter{Appendix 1}
\lipsum

\cleardoublepage
\setlength{\columnsep}{0.75cm}
\addcontentsline{toc}{chapter}{\textcolor{ocre}{Index}}

\markboth{\sffamily\normalsize\bfseries\indexname}{}
\printindex
\lipsum

\end{document} 

You must log in to answer this question.

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