I fight with the strange and useless entries of the index in dtx files.

It can reproduced with

% \iffalse

% \fi
% \DescribeMacro{\foobar} Prints out foobar
% \Finale

the result is

foobar= \subitem *+\foobar+, \usage{1}

printed as shown here in the pdf.

Anyway: I would like to switch of the index functionality of doc.sty completely and replace it with my own. It tries to add EVERY latex command used in the index. With my current code this is hundrets of entries which have nothing to do with any command defined by the package.


1 Answer 1


If I run

makeindex -s gind.ist dtxcode

the content of the resulting .ind file is

{\bfseries\hfil F\hfil}\nopagebreak

  \item \verb*+\foobar+\pfill \usage{1}


If instead I run the wrong command

makeindex dtxcode

the resulting file contains


  \item foobar=\verb
    \subitem *+\foobar+, \usage{1}


which is obviously wrong.

Indexing of a macro is suppressed by adding it as the argument to a \DoNotIndex command (there can be many, each receiving lists of macro names); for instance (from one .dtx of mine)

% \DoNotIndex{\newcommand,\newenvironment,\!,\@empty,\@gobble,\@gobbletwo}
% \DoNotIndex{\@ifpackageloaded,\@ifpackagewith,\@ifundefined,\@namedef}
% \DoNotIndex{\@nil,\@onlypreamble,\@tempa,\@tempb,\@tempswafalse,\def}

(I like that one command doesn't spill over the next line.)

It's customary that a DTX file has the .dtx extension, rather than .tex

  • Where does -s gind.ist come from? Nov 29, 2012 at 21:39
  • gind.ist is the MakeIndex style specifically tailored for building the index for a .dtx file. See section 2.9 of the documentation of the .dtx format (texdoc doc)
    – egreg
    Nov 29, 2012 at 22:00
  • Yes that corrects it. I would however prefer if the whole makeindex styleing was made in tex code as it does biblatex. The not indexing of commands is quite long (spills over 10 lines in the editor). To me this looks like a design problem of doc.sty. Nov 30, 2012 at 19:36
  • Hello @egreg, I am working on a package which has some code which has \somemacro\ some text written. When I print the index with l3doc I see a list of symbols in which the program prints \␣. Now I understand why this happen, but as this isn't intended, I tried \DoNotIndex{\ ,\othermacros}, \DoNotIndex{\csname\space\endcsname,\othermacros}, but nothing seems to work. Can you suggest a fix?
    – Niranjan
    Sep 6, 2022 at 16:30
  • @Niranjan Please, make a new question with the details and an example.
    – egreg
    Sep 6, 2022 at 16:44

You must log in to answer this question.

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