3

To create an index entry in OPmac one enters something like this:

Oh, how I like \ii figs figs.

Notice the repetition there? As a convenience OPmac provides \iid:

Oh, how I like \iid figs .

In this case, I didn't need to repeat the word "figs", though I did have to enter a space between the "s" and the "." in order for the sentence to be typeset correctly.

Unfortunately, the following does not typeset correctly:

Oh, does anyone else like \iid figs ?

In this case, instead of "figs?" being typeset, we get "figs ?" - with that space.

The culprit seems to be here:

\def\iiD{\ifx\tmp,\else\ifx\tmp.\else\space\fi\fi} % comma and period handled

I modified to include a question mark ("?") with

\def\iiD{\ifx\tmp,\else\ifx\tmp.\else\ifx\tmp?\else\space\fi\fi\fi}

but obviously other punctuation such as exclamation points, colons, semi-colons, etc are needed. Is there a better way to handle this perhaps?

2
  • Of course, you can redefine \iiD but you need to use the right number of \fis at the end of the macro. IMHO the other punctuation isn't frequent, than you can use \ii figs figs? or \iid figs \unskip?. Of course, you can use the claccical approach with braces and repeation: \iindex{figs}figs?.
    – wipet
    Jun 21, 2014 at 4:25
  • @wipet -- I fixed the missing \fi in the question. Thanks.
    – acarlow
    Jun 21, 2014 at 5:57

1 Answer 1

2

There is a possibility to redefine the \iid macro in order to do it more intelligent. The point is that the parameter of \iid is separated by space (instead of two braces) in order to spare typing. But may be, two braces are useful sometimes.

\let\iidC=\iid
\def\iid {\futurelet\next\iidA}
\def\iidA {\ifx\next\bgroup \expandafter \iidB\else \expandafter \iidC \fi}
\def\iidB #1{\iindex{#1}#1}

Now you can use \iid word followed by space or \iid {word} without following space. In your case: \iid{figs}?.

You must log in to answer this question.

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