I'm using \EnableCrossrefs in a dtx file. In the index I now have \, indexed.
I tried \DoNotIndex{{\,}} and \DoNotIndex{\thinspace} without success.
Is there a way to prevent the inclusion of \, in the index?
I'm using \EnableCrossrefs in a dtx file. In the index I now have \, indexed.
I tried \DoNotIndex{{\,}} and \DoNotIndex{\thinspace} without success.
Is there a way to prevent the inclusion of \, in the index?
\DoNotIndex{\,} works by accident:
\DoNotIndex changes the catcode of \ to 12 (other) and adds \,, to the list of excluded commands, the token register \index@excludelist. The second comma is the separator.
Macro \ifnot@excluded then looks for the string consisting of a backslash \, the macro name part and the separator comma , in the list for a match using LaTeX's \@@in in the end. Because \, contains already a comma, the algorithm gets confused does not interpret the comma as macro name, but as separator comma. Therefore \, is found in the list of excluded commands.
\{ and \} work with a trick. Because \DoNotIndex changes the catcode of the backslash \, the curly braces are not properly nested anymore. Also catcode 12 (other) is needed for the curly braces. Thus \string helps as the example shows.An example that shows the exclusion of \,, \{, and \}:
% \iffalse
% arara: pdflatex: {draft: yes}
% arara: makeindex: {style: gind}
% arara: pdflatex
%<*driver>
\documentclass{ltxdoc}
\CodelineIndex
\EnableCrossrefs
\IndexPrologue{}
\DoNotIndex{\,}
\expandafter\DoNotIndex\expandafter{\string\{}
\expandafter\DoNotIndex\expandafter{\string\}}
\begin{document}
\DocInput{\jobname.dtx}%
\end{document}
%</driver>
% \fi
% \begin{macrocode}
%<*package>
\relax \, \thinspace \{ \}
%</package>
% \end{macrocode}
%
% \PrintIndex
% \Finale
Just putting
\DoNotIndex{\,}
should work, no need for redundant braces.
If you want to add more things that don't need to be indexed, you can simply add a comma:
\DoNotIndex{\,,\addtocounter}
\{and\}. – karlkoeller Jul 20 '13 at 17:03\#,\$,\%,\^,\_,\~,\, and\&are also problematic. See here for explanation and possible workarounds. – Robert Jul 20 '13 at 17:13