[NTG-context] Bad interaction between new interpretation of underscore and modules

Wolfgang Schuster schuster.wolfgang at googlemail.com
Fri Jan 14 10:32:20 CET 2011


Am 14.01.2011 um 10:15 schrieb Mathieu Boespflug:

> Thank you for the solution, Wolfgang.  But it seems rather painful to
> have to replace every occurrence of _ in my definitions module with
> the very verbose \normalsubscript just because it's a module. The new
> default catcode for _ introduces extra difficulty when defining math
> macros. Would it be possible to at least have a macro to revert to the
> old behaviour? Also, I'm still stumped as to why modules make any
> difference here. I would have expected this problem to also show up if
> the definitions were made inline at the top of the source file for the
> document.

When you write a module you put \unprotect and \protect at the begin and
end of the file because they make @, !, ? and _ to a normal letter like abc
which can be used in macros. When you load a file with \usemodule or
\environment this isn’t necessary because context adds already calls
both commands when the file is opened and closed for reading and this
mechanism is used even if you aren’t aware of this.

PS  For \environment this is only true when you use it in a document
with \starttext or when you write it before \startproduct, \startcomponent etc.

PPS  You can abuse \nonknuthmode to make your module to work

\startbuffer[definitions]
\pushcatcodes\nonknuthmode % \startnonknuthmode
\def\lambdax{\lambda_x}
\popcatcodes               % \stopnonknuthmode
\stopbuffer

\savebuffer[definitions][p-definitions.tex]

\startbuffer[more]
\def\morex{\more_x}
\stopbuffer

\savebuffer[more][p-more.tex]

\usemodule[definitions,more]

\starttext
blah $\lambdax$ blah. \morex
\stoptext

Wolfgang



More information about the ntg-context mailing list