4

Is it possible to use ltxdoc.cls with makeidx and bookmark?

MNWE:

\documentclass{ltxdoc}
\usepackage{makeidx}
\usepackage{bookmark}
\makeindex
\begin{document}
\DescribeMacro{\mymacro}\marg{argument}\par
\printindex
\end{document}

Following the advice in comments, I then tried

makeindex -s gind.ist prawf

Here's makeindex's transcript:

This is makeindex, version 2.17 [TeX Live 2023] (kpathsea + Thai 
support).
Scanning style file /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist.............done (13 attributes redefined, 3 ignored).
Scanning input file prawf.idx...done (0 entries accepted, 1 rejected).
Nothing written in prawf.ind.
Transcript written in prawf.ilg.

The log:

This is makeindex, version 2.17 [TeX Live 2023] (kpathsea + Thai support).
Scanning style file /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist..........
** Input style error (file = /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist, line = 75):
   -- Unknown specifier lethead_prefix.
** Input style error (file = /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist, line = 76):
   -- Unknown specifier lethead_suffix.
** Input style error (file = /usr/local/texlive/2023/texmf-dist/makeindex/latex/gind.ist, line = 77):
   -- Unknown specifier lethead_flag.
...done (13 attributes redefined, 3 ignored).
Scanning input file prawf.idx...
!! Input index error (file = prawf.idx, line = 1):
   -- Extra `|' at position 46 of first argument.
done (0 entries accepted, 1 rejected).
Nothing written in prawf.ind.
Transcript written in prawf.ilg.

The raw index file is

\indexentry{mymacro=\verb!*+\mymacro+|hdclindex{2}{usage}|hyperpage}{1}
11
  • 3
    you do not need doc as that is loaded, use a makeindec style using different special characters such as the gind.ist file distributed with doc. Aug 21, 2023 at 5:56
  • BTW: TeX Live provides mkindex that processes the .idx and .glo files of a document using (makeindex and) gind.ist resp. gglo.ist.
    – cabohah
    Aug 21, 2023 at 7:20
  • @DavidCarlisle TEXMFHOME=/d makeindex -s gind.ist prawf? I have to set the file up to use something different, too, I guess. (I don't make indexes often.) Thanks re. the doc. I discovered I'm not explicitly loading it in the actual document, but added it for the MNWE. I know doc provides indexing macros, but I don't know if I should be using those or not. (I don't have a dtx.)
    – cfr
    Aug 21, 2023 at 15:05
  • 1
    ltxdoc is essentially article class plus doc package, so doc is loaded before you specify it, Aug 21, 2023 at 15:28
  • @DavidCarlisle Could you suggest what I need to do beside -s gind.ist?
    – cfr
    Sep 4, 2023 at 18:49

1 Answer 1

4

You get a warning in the log:

Package hypdoc Warning: hyperref has been loaded before. Check the options! 

hypdoc loads at the end of the preamble hyperref with the option hyperindex=false to avoid that it interferes but as you already load hyperref through the bookmark package this no longer works.

Sadly it is not trivial to disentangle 30 years of history and to avoid this loading order problem: currently the hyperindex can't be reset after the package.

The easiest currently for you is to load hypdoc earlier, before hyperref:

\documentclass{ltxdoc}
\usepackage{makeidx}
\usepackage{hypdoc}
\usepackage{bookmark}
\makeindex
\begin{document}
\DescribeMacro{\mymacro}\marg{argument}\par
\printindex
\end{document}

Additionally, as already mentioned in the comments, you must call makeindex with a special style e.g. -s gind then you get this

enter image description here

1
  • Thank you so much! I was trying to do completely the wrong thing. I thought I needed hyperindex, so I tried to make sure it had that. Then I realised it was enabled anyway, so I thought the problem must be something else.
    – cfr
    Sep 9, 2023 at 15:13

You must log in to answer this question.

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