0

This question already has an answer here:

Consider this basic .tex file:

\documentclass[12pt, a4paper, draft]{book}
\usepackage{makeidx}
\makeindex
\newcommand{\withIndex}[1]{#1\index{$#1$}}
\newcommand{\myIndex}[1]{\index{$#1$}}
\begin {document}
\section{Test section}

Some test text \index{text}.

A $\Downarrow$ \index{$\Downarrow$} represents....\\
Another \withIndex{$\Downarrow$} represents...\\
Perhaps $\Downarrow$ \myIndex{$\Uparrow$} represents...\
\printindex
\end {document}

I have the \withIndex command defined on line 4 in my document, and it works well for the majority of symbols. However, when certain symbols are used with this command odd results are produced. Calling \withIndex($\Downarrow$} in the document body puts the key ${\Gamma}B37F$ into the index (to give another example, indexing $\langle$ in this way gives the key 'hA').

Naturally, I want to see the \Downarrow symbol appear in the index (or the left angled bracket in my other example). The \myIndex command produces the same result, but \index{$\Downarrow$} gives the correct output. Why do I get such strange index output for these particular symbols with the \withIndex command?

marked as duplicate by egreg, Heiko Oberdiek, Mensch, mafp, Xavier May 14 '13 at 0:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    This question is very similar to Symbol index sorted by occurrence. Look if it helps you. – egreg May 13 '13 at 23:35
  • 1
    You shouldn't add $ in the definition of \myIndex and \withIndex, though, if you plan to call \withIndex{$\Downarrow$}, because this would result in $$ in the index file. – egreg May 13 '13 at 23:47
  • Ah yes indeed, thanks for pointing that out. I'll make that edit in my file. – John Pirie May 13 '13 at 23:49

Browse other questions tagged or ask your own question.