Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!chalmers.se!cs.chalmers.se!jeffrey From: jeffrey@cs.chalmers.se (Alan Jeffrey) Newsgroups: comp.text.tex Subject: Re: Math mode in LaTeX Message-ID: <4648@undis.cs.chalmers.se> Date: 1 Jun 91 10:34:50 GMT References: <1991May15.205919.12393@serval.net.wsu.edu> <1991May28.070140.16324@neon.Stanford.EDU> Organization: Dept. of CS, Chalmers, Sweden Lines: 40 In article <1991May28.070140.16324@neon.Stanford.EDU> espie@ibis.Stanford.EDU (Marc Espie) writes: >So, now redefining !thing! to act like \mbox{thing} is not really >difficult. Here is a quick answer, it should work with little or no >modification. >---- >\catcode`\!=\active >\def\leavemath{\egroup\let!=\entermath} >\def\entermath{\let!=\leavemath\mbox\bgroup} >\let!=\leavemath >---- Except that this will produce strange results for writers with a tendency to use exclaimation marks in their text! You could try \newtoks\everytext \newtoks\everyendtext \def\textshriek{!} \catcode`\!=\active \def!{\relax\ifmmode\expandafter\mathshriek\else\textshriek\fi} \def\mathshriek#1!{\hbox{\the\everytext#1\the\everyendtext}} This also gives you token lists \everytext and \everyendtext, which are used at the beginning and end of every !...! pair. For example, if you want all of this text to be set in the upright font, with a quad space before and after, you could say \everytext{\normalshape\quad} \everyendtext{\quad} Exercise for the interested reader: why the \relax and why the \expandafter? (The answers to these questions, as with any other you may have about life, the universe and everything, are kept within the covers of the TeXbook.) Alan. -- Alan Jeffrey Tel: +46 31 72 10 98 jeffrey@cs.chalmers.se Department of Computer Sciences, Chalmers University, Gothenburg, Sweden