# “Top Level” category for indexes in OPmac

Is there a way to create a "top level" index entry in OPmac without a page number?

I'd like it to look something like this:

figs
-- green 1
-- newtons 3
-- red 2


Notice, there is no page number after the word figs (in this example perhaps there are only references to the three specific fig types in the text).

My current solution is this:

\def\indexcat#1{\openref\wref\Xindex{{#1}{}}} % No Page Number entry
\indexcat{figs}


But I was thinking there might be a built-in way instead of manually writing to the reference file like this.

Here's a little MWE to play with if you'd like:

% Process twice to get the index
\input opmac
This is the first page which talks about \ii figs \ii figs/green green figs.
\vfil\eject
\vfil\eject
And finally we have \ii figs/newtons fig newtons, which frankly one wonders if that's real fig in there...
\vfil\eject
\nonum\sec Index

\makeindex

\bye


(Notice that I had to put the rather annoying lone \ii figs entry to even get a bare top level entry -- though with page number. Try the MWE without \ii figs on the first line to see what I mean.)

• I don't understand why your elegant solution isn't suitable. I'd define the same but with space as a separetor \def\iin #1 {\openref\wref\Xindex{{#1}{}}} (Insert to Index with No pages). User can declare all such words at beginning of the document (for example) \iin figs \iin bannas \iin coconuts  or somwhere in the place where the words are mentioned. I don't see the problem. – wipet Jun 21 '14 at 5:27

\def\iin #1 {\openref\wref\Xindex{{#1}{}}} % Insert to Index with no page number

Then, for every "top level" index item needed, \iin .... could be added (likely somewhere at the top of the document.)
(Notice the space after the #1 in the definition -- this obviates the need for the curly brackets around the parameter as long as it doesn't contain spaces itself.)