> > It's an issue with eqn material inside a macro definition. > > To avoid expanding eqn-generated escapes at macro definition > > time, bracket the macro definition with ".ec #" (or some other > > unused character) and ".ec" (to restore backslash as the escape > > character after the macro definition). This way, backslashes > > are retained in the macro and escapes are only evaluated at > > macro expansion time.
> If this problem is not only in-line EQN code but also .EQ/.EN code, EQ/EN and in-line eqn code are identical. > then it would seem to me that any EQN code inside a groff/troff > macro is to be avoided. Anything else seems like a recipe > for disaster. Not at all. One only has to understand what causes these issues and then handle them appropriately. Normally, one would double all backslashes inside a macro definition because escapes are also evaluated at macro definition time (copy mode). Each double backslash is interpreted as a single backslash inside the macro, so that the "real" interpretation of the escapes is delayed until macro expansion time (when the macro contents are re-read and all still existing escapes are re-interpreted). However, eqn doesn't have a "double all backslashes" option to be used inside a macro definition (and even if it did, how would eqn know which code is in a macro and which isn't, without doing all the work that troff does?). The solution is to not interpret backslashes at macro definition time. This is achieved by declaring a different character[*] to be used as the escape character before defining the macro, and reinstating backslash as the escape character after the macro definition(s). This approach can also be used independently of eqn if you simply want to avoid all the backslash-doubling hassle while defining macros. Obviously, when using this approach to deal with eqn code inside macros that also contain other escapes, you must not double the other non-eqn backslashes in the macro either. On the other hand, sometimes you *do* want escapes to be evaluated at macro read time (e.g., converting \t to a tab), in which case you would have to use the new escape character instead of the backslash. [*] I recommend ascii BEL = control-G because it is unlikely to be used elsewhere in the manuscript.