🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #5726

Re: TeX macro for Nuclear Physics symbols

#5726
From: Raymond Juimong Chen
Date: Fri, 20 Jan 1989 04:53
70 lines
3290 bytes
% Gosh, this was a fun challenge!  Here's my shot.

\catcode`@=11 % make macros that should remain inaccessible inaccessible.

\newtoks\@lement % remember the element.
\def\Ni{\@lement={Ni}\g@tisotope}
\def\O{\@lement={O}\g@tisotope}
% You get the idea.

% We now pull a really dirty trick.
% Since it is hard to grab a number from the input stream, we ask
% \TeX\ to do it for us...  The trick is to store the number into
% a scratch \count register, then wake up.  We do this via an
% \afterassignment.

% the unpleasant side-effect is that one space token is eaten up
% after the number.  This can be gotten-around by collecting the
% digits explicitly (as a previous attempt at this did), but
% it's just so much less elegant.  (You have to write a macro
% which recognizes digits, and then play games with \futurelet
% the way the \prim@s macros do in plain.tex.  It's ugly.)
% So instead, if you want a space,
% you'll have to put it in yourself.  (A previous attempt put the
% space in explicitly, but that was just too yucky, since very
% often, a symbol will appear at the end of a clause.)  This shouldn't
% be too much of a hassle, since you're already used to putting
% explicit spaces after control sequences, right?

% the token \b@ck will tell us how to get back to whatever
% we were doing before it all started.  That is, it will be \relax
% if we were already in math mode, otherwise it will be $.

% Okay, dive in!
% We put the isotope number into \count0, then ask \g@tis@tope to
% finish up.

\def\g@tisotope{\let\b@ck\relax\ifmmode\else$\let\b@ck$\fi
\afterassignment\g@tis@tope\count0=}

% ah, so now we can do what needs to be done.  It's all easy sailing
% from here.

\def\g@tis@tope{{}^{\number\count0}{\rm\the\@lement}\b@ck}

\catcode`@=12 % yay.

% Now, let's test it.
% Note:  I'm a mathematician, not a nuclear physicist.  This will be nonsense,
% but it illustrates the macros.

% note the explicit space here -----vv
It is important to notice that \Ni19\ reacts violently when
exposed to \O23, a very rare isotope.
The compound~\Ni19\O23, a very important \Ni19-derived compound,
is relatively inert.  Moreover, the complex
$\Ni19(\O23_3\O16_2)_3$ is kind of yuccky-tasting.

\end

Courtesy of your local TeXacker (who finished his last final exam 
a few hours ago, yay!)...
--
Raymond Chen	UUCP: ...allegra!princeton!{phoenix|pucc}!rjchen
		BITNET: rjchen@phoenix.UUCP, rjchen@pucc
		ARPA: rjchen@phoenix.PRINCETON.EDU, rjchen@pucc.PRINCETON.EDU
-- 
Raymond Chen	UUCP: ...allegra!princeton!{phoenix|pucc}!rjchen
		BITNET: rjchen@phoenix.UUCP, rjchen@pucc
		ARPA: rjchen@phoenix.PRINCETON.EDU, rjchen@pucc.PRINCETON.EDU
"Say something, please!  ('Yes' would be best.)" - The Doctor
Technical Details
Message-ID: <5619@phoenix.Princeton.EDU>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!purdue!gatech!udel!princeton!phoenix!rjchen
References: <676@ur-cc.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!purdue!gatech!udel!princeton!phoenix!rjchen
From: rjchen@phoenix.Princeton.EDU (Raymond Juimong Chen)
Newsgroups: comp.text
Subject: Re: TeX macro for Nuclear Physics symbols
Message-ID: <5619@phoenix.Princeton.EDU>
Date: 20 Jan 89 04:53:57 GMT
References: <676@ur-cc.UUCP>
Reply-To: rjchen@phoenix.Princeton.EDU (Raymond Juimong Chen)
Distribution: na
Organization: Princeton University, NJ
Lines: 70