[comp.text.tex] Equations without escape characters: help wanted

rhw@hoh-1.att.com (robert.h.wentworth) (06/14/90)

Here's a TeX problem that's been driving me nuts.  A friend complains
that the equations in TeX aren't as readable as the equations in
troff (eqn) because all the backslashes keep grabbing his eye.  He
would like to see things set up so that you can just type text
and within mathmode any strings that correspond to defined control
sequences will be recognized as such while letter sequences that
don't correspond to control strings would be handed in the usual
way. (He doesn't want to just change the escape character.)  Outside
of mathmode everything could/should be handled in the usual way, including
the need to use backslashes for command sequences.

Thus if you typed:

$$ x={a over b}z^{cos theta} $$

this would be interpreted as the more conventional:

$$ x={a \over b}z^{\cos\theta} $$

One could require spaces around all keywords, though this would be
slightly less desirable.  Some nuances that an ideal solution might
take into account include: (i) There should be a mechanism for typing
sequences of letters and having them not be expanded into the corresponding
control sequence; since spaces are generally ignored in math mode (are
there relevant cases where they're not?) the solution could be to insert
spaces into multi-letter strings in danger of conversion to a control
sequence. (ii) Since plain TeX defines a variety of single-letter control
sequences, isolated letters probably shouldn't be converted to control
sequences unless an explicit backslash is present.

I thought this performance (without the nuances for now) should in principle
be doable, but I've expended a considerable amount of effort on this so far
without success.  Can anyone propose a solution to this problem?

%---------------------------------------------------------------------------

You may have an independent approach to the above problem, and if so the
following might just put you on the wrong track. Still...

I've written what seemed like near-solutions that got stuck on seemingly
unsolvable crux problems.  My preferred approach has involved setting the
mathcode for all letters to "8000 so as to render them active in mathmode.
(Spaces might also need to have their mathcode changed in order to render
them detectable when they delimit words, but I haven't addressed this issue
yet.)  This leads to some secondary problems related to apparently deep
problems in generating inactive letter tokens in a context where letters are
generally active.  The first subproblem is how to refer to the letters when
I really want to print them; I think a workable solution to this is to just
use explicit \mathchar<number> statements to refer to the relevant letter.
The less tractable (so far unsolved) subproblem is how to generate control
sequences from characters.  Something like:
	\catcode`@=10
	\def\@@@@@#1{\csname#1\endcsname}
	$$ \@@@@@{cos} $$
doesn't work when c,o,s are active in mathmode, nor does any convoluted
and (I thought) clever variation that I can come up with.

An alternative (less desirable because it requires space delimiters) is
to only make spaces active.  This approach ought to work, but my initial
attempts failed for unknown reasons.

Yet another approach which I haven't tried would involve instead of making
characters active, placing a macro (perhaps hidden) at the beginning of
each equation which would read subsequent tokens and make appropriate
translations.  Might have difficulty coping with nested macro expansions
(or not?) or embedded \hbox constructs which use horizontal mode.


Comments on any of the issues brought up here would be welcome.
(I'd appreciate direct replies to rhw@hoh-1.att.com since I don't
reliably read this newsgroup.
-- 
Robert H. Wentworth (201)888-7195 |"Give me back my innocence
AT&T BL HOHL-171, Holmdel NJ      | Get me a a new Cadillac
rhw@hoh-1.att.com		  | Cause when I get on up to heaven Lord
att!hoh-1!rhw			  | You can have it all back" -L.Anderson