我正在使用以下代码作为我的索引。
\documentclass[a4paper,11pt,twoside, openleft]{book}
\usepackage{makeidx}\makeindex
\newcommand*{\formatfirst}[1]{\MakeUppercase{#1}}
\makeatletter
\newcommand*{\mymacro}[1]{%
\expandafter\formatfirst\expandafter{\@car #1\@empty\@nil}%
\@cdr #1\@empty\@nil}
\newcommand*\boldindexhardcode[1]{%
\def\@boldindexhardcode{\boldindexhardcode@i#1 \@nil}%
{\itshape\@boldindexhardcode}\index{#1@\@boldindexhardcode}}
\def\boldindexhardcode@i#1 #2\@nil{%
\mymacro{#1}%
\ifx\\#2\\%
\else
\@ReturnAfterFi{%
\space
\boldindexhardcode@i#2\@nil
}%
\fi}
\long\def\@ReturnAfterFi#1\fi{\fi#1}
\makeatother
\newcommand{\boldindex}[1]{ \textcolor{DarkPurple}{\textbf{\boldindexhardcode{#1}}}}
\begin{document}
\chapter{Chapter}
\boldindex{Test}\\
\boldindex{tEst}\\
\boldindex{teSt}\\
\boldindex{tesT}
\printindex
\end{document}
我怎样才能删除奇怪的斜体文本,同时保留粗体文本?
答案1
移除\itshape
newcommand*\boldindexhardcode[1]{…}