2

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
On this page we talk about everyone's love of \ii figs/red red figs which are delicious.
\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
2

As @wipet's comment (the author of OPmac) indicates, a reasonable solution, and one keeping in the spirit of OPmac itself is a slight modification of my initial attempt:

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

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

| improve this answer | |

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.