%D \module %D [ file=m-electrons, %D version=2024.10.30, %D title=\CONTEXT\ Extra Modules, %D subtitle=messing with electrons, %D author=Hans Hagen, %D date=\currentdate, %D copyright={\CONTEXT\ Development Team}] % This is a follow up on mails to the list by Jorge and Bruce. \startmodule [m-electrons] \unprotect \installcorenamespace {electrons} \installcommandhandler \??electrons {electrons} \??electrons \setupelectrons [\c!textstyle=\tfxx, \c!distance=.5\strutdp, \c!depth=.5\strutdp] \starttexdefinition tolerant protected electrons[#1]#*#:#=#= \dontleavehmode \begingroup \ifparameter#2\or \cdef\currentelectrons{#1}% \fi \setbox\scratchboxone\hpack\bgroup \doloopovermatch {.} {#2} { \framed [\c!strut=\v!no, \c!width=\lineheight, \c!height=\lineheight] {\useelectronsstyleandcolor\c!style\c!color \symbol[electron##1]} \hskip-\linewidth } \unskip \egroup \ifparameter#3\or \setbox\scratchboxtwo\hbox to \wd\scratchboxone\bgroup \useelectronsstyleandcolor\c!textstyle\c!textcolor \setstrut\strut \hss#3\hss \egroup \setbox\scratchboxone\hpack \bgroup \box\scratchboxone \hkern-\wd\scratchboxtwo \boxymove\scratchboxtwo\dimexpr -\htdp\scratchboxtwo +\electronsparameter\c!distance \relax \box\scratchboxtwo \egroup \fi \boxymove\scratchboxone-\electronsparameter\c!depth \box\scratchboxone \endgroup \stoptexdefinition \definesymbol[electronu][\m{\upharpoonleft}] \definesymbol[electrond][\m{\downharpoonright}] \definesymbol[electronb][\m{\upharpoonleft\downharpoonright}] \definesymbol[electronB][\m{\darkred \symbol[electronb]}] \definesymbol[electronD][\m{\darkblue\symbol[electrond]}] \stopmodule \protect \continueifinputfile{m-electrons.mkxl} \usemodule[scite] \starttext \startTEXpage[offset=1cm,width=17cm] \startbuffer[b] Nitrogen: \electrons{b}{1s} \electrons{b}{2s} \electrons{uuu}{2p} Nitrogen: \electrons{b}{} \electrons{B}{} \electrons{uDu}{} \defineelectrons [nitrogen] \setupelectrons [nitrogen] [color=darkgreen] Nitrogen: \electrons[nitrogen]{b}{} \electrons[nitrogen]{B}{} \electrons[nitrogen]{uDu}{2p} \stopbuffer \typebuffer[b][option=TEX] \getbuffer[b] \stopTEXpage \setuplayout[tight] \typefile[option=TEX]{m-electrons.mkxl} \stoptext