TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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

share|improve this question
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 '14 at 4:25
@wipet -- I fixed the missing \fi in the question. Thanks. – acarlow Jun 21 '14 at 5:57
up vote 1 down vote accepted

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.

\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}?.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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