0

I'm using the following code for my index.

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

It renders like this: enter image description here

How am I able to remove the weird italic text, while keeping the bold text?

3
  • Remove \itshape from newcommand*\boldindexhardcode[1]{…}.
    – Bernard
    Commented Jul 7, 2021 at 9:57
  • Thank you so much! How do I close the question?
    – superHenry
    Commented Jul 7, 2021 at 10:07
  • I don't know exactly. Sometimes I see in a comment someone proposing to close a question, as it was solved in comments. Maybe, click on ‘Close’ at the bottom.
    – Bernard
    Commented Jul 7, 2021 at 10:21

1 Answer 1

-1

removing \itshape from newcommand*\boldindexhardcode[1]{…}

1
  • 1
    You just repeat the @Bernard comment ...
    – Zarko
    Commented Jul 7, 2021 at 18:50

You must log in to answer this question.

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