在章节缩略图中显示“索引”而不是“附录”

在章节缩略图中显示“索引”而不是“附录”

在下面的代码中,我希望能够让“索引”显示在标题中,并且让章节缩略图显示在文档的索引部分中。

\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} 

答案1

您需要做的就是更换

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

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

完整代码

\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} 

相关内容