0

I refer to Still problems with multiple indexes in ltxdoc

The solution given there works for that simple MWE, but in my real project I encounter a more serious problem. The next M_not_WE shows it. When I run "pdflatex testidx.dtx" it responds with:

! Undefined control sequence.
\special@index ...w \immediate \write \@indexfile
  {\string \indexentry
{#1}{...
l.26 % \begin{macro}{\my@macroA}

When I comment out the line "\CodelineIndex" it runs through

What is wrong with my code?

% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage{imakeidx}
\CodelineIndex
\EnableCrossrefs
\indexsetup{level=\section*}
\makeindex[name=other]
\makeindex[options=-s gind.ist,title={General Index}]
\begin{document}
  \DocInput{testidx.dtx}
\end{document}
%</driver>
% \fi
%
% \DescribeMacro{\my@macroA}
% \DescribeMacro{\mymacroB}
%
% \StopEventually{}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
% \begin{macro}{\my@macroA}
%    \begin{macrocode}
\def\my@macroA{A}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mymacroB}
%    \begin{macrocode}
\def\mymacroB#1{B#1}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\endinput
%    \end{macrocode}
%
% \iffalse
%</package>
% \fi
%
% \Finale
\printindex
\printindex[other]
\endinput
1

There were no responses at all, so I answer my own question. After some experimenting I found a solution by not using imakeidx at all. What I did is essentially this (remember that I wanted to have a list of user commands at the end of the documentation of my package, using ltxdoc):

First I write the commands in a file with some formatting stuff. I thereby use hyperref to get a clickable index. At the end I read this file to get the list.

Prelimary Stuff

\newwrite\UCFile
\DeleteShortVerb{\|}
\immediate\openout\UCFile="| sort -d > \jobname.odw
\MakeShortVerb{\|}

Read the commands

\newcommand\bs{\texttt{\textbackslash}}
\newcommand\usercom[1]{%
  \label{#1}\immediate\write\UCFile{%
    \noexpand\hyperref[#1]{\noexpand\bs#1,
    \thepage\noexpand\newline}}%
}

Example of a call

\DescribeMacro{\CompassMid}\usercom{CompassMid}

Write the file

\immediate\closeout\UCFile
\begin{multicols}{3}[\section{List of User Commands}]
  \IfFileExists{\jobname.odw}
     {\noindent\input{\jobname.odw}}
     {\PackageWarning{ODw}{File \jobname.odw not found}}
\end{multicols}

Remark

pdflatex must be called with the option --shell-escape

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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