TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 8 down vote accepted

Just putting


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:

share|improve this answer
I suspect this doesn't work – Joseph Wright Jul 20 '13 at 16:42
@karlkoeller Wow, that's spooky, this really works! I didn't try this, because i thought this will never ever work! ;-) – Josef Jul 20 '13 at 16:58
AFAIK, it doesn't work only for \{ 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
@Robert thanks, I was not aware of them. – karlkoeller Jul 20 '13 at 18:06

\DoNotIndex{\,} works by accident:

  1. \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.

  2. 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.

  • Also \{ 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
% \fi
%    \begin{macrocode}
\relax \, \thinspace \{ \}
%    \end{macrocode}
% \PrintIndex
% \Finale


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.