2

In my LaTeX document, I write this:

\index{chi@$\chi^2$-score}

In another place I write this:

\index{chi@$\chi^2$-score|textbf}

The first is rendered in the idx file as I would expect:

\indexentry{chi@$\chi^2$-score|hyperpage}{39}

But the second appears in the idx file as

\indexentry{chi@$\mitchi ^2$-score|hyperindexformat{\textbf}}{55}

What even is \mitchi? A web search returns nothing helpful... is it even a valid LaTeX command? It must be... because the index renders correctly in the resulting PDF.

Both index entries appear in the index, and appear formatted correctly, but as different entries (of course).

Can anyone help me? Where did the elusive $\mitchi$ come from, and what even is that?

P.

1
  • You likely have the second \index in the argument to another command. Please, add a minimal example.
    – egreg
    Apr 23 at 7:35

2 Answers 2

5

You have shown no usable example but you are presumably using unicode-math or a package compatible with it.

unicode-math defines:

\UnicodeMathSymbol{"1D712}{\mitchi }{\mathalpha}{mathematical italic small chi}%

That is: U+1D712 is math italic chi, \mitchi.

3
  • Thanks David. Still seems odd (to me; I'm sure there's a good reason) it is used in one case, but not the other... Any advice for how to make both index entries in the idx file similar, so they are indexed together?
    – Pete
    Apr 23 at 0:38
  • 2
    @Pete You should always provide an example but apart from guessing that you are using unicode-math I would guess that one instance is at the top level so the argument on \index is written verbatim, and the other is inside the argument of another command so verbatim doesn't work and the command expands. use \foo{\index{...}} with \newcommand\foo[1]{#1} then they should work the same way Apr 23 at 0:46
  • Thanks for some direction, David. This is all part of a very large project, with lots of packages I need to add that I don't know a lot about... I had never seen \mitchi before... or had this issue before... so had no idea where to start, or which packages may be responsible.. Appreciate your time. I now know where to start.
    – Pete
    Apr 23 at 0:52
3

I can easily reproduce the issue:

\documentclass{article}
\usepackage{makeidx}
\usepackage{unicode-math}
\usepackage{hyperref}

\makeindex

\begin{document}

Here's a $\chi$\index{chi@$\chi^2$-score}

\textbf{Here's a $\chi$\index{chi@$\chi^2$-score|textbf}}

\printindex

\end{document}

If \index is in the argument to another command, LaTeX cannot use the “semiverbatim” mode it can use at the outer level.

Indeed, the entries in the idx files are

\indexentry{chi@$\chi^2$-score|hyperpage}{1}
\indexentry{chi@$\mitchi ^2$-score|hyperindexformat{\textbf}}{1}

The “semiverbatim” mode is not generally needed, if you're constantly using @ for complex index entries like you seem to be doing.

\documentclass{article}
\usepackage{makeidx}
\usepackage{unicode-math}
\usepackage{hyperref}

\makeindex

\NewCommandCopy{\oldindex}{\index}
\RenewDocumentCommand{\index}{m}{\oldindex{#1}}

\begin{document}

Here's a $\chi$\index{chi@$\chi^2$-score}

\textbf{Here's a $\chi$\index{chi@$\chi^2$-score|textbf}}

\printindex

\end{document}

The contents of the .idx file

\indexentry{chi@$\mitchi ^2$-score|hyperpage}{1}
\indexentry{chi@$\mitchi ^2$-score|hyperindexformat{\textbf}}{1}

enter image description here

1
  • Thanks so much @egreg. As stated, this is a large and complex project, and I cannot see any explicit call to load unicode-math, so it must be within one of the other packages loaded. You've saved me a lot of time. It now works.
    – Pete
    Apr 23 at 22:49

You must log in to answer this question.

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