%D \module %D [ file=math-scr, %D version=2007.07.19, %D title=\CONTEXT\ Math Macros, %D subtitle=Scripts, %D author=Hans Hagen, %D date=\currentdate, %D copyright=\PRAGMA] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. \writestatus{loading}{ConTeXt Math Macros / Scripts} \unprotect %D \macros %D {super, sub} %D %D \TEX\ uses \type{^} and \type{_} for entering super- and %D subscript mode. We want however a bit more control than %D normally provided, and therefore provide \type {\super} %D and \type{sub}. %D %D The grid snapping has been removed. \global\let\normalsuper=^ \global\let\normalsuber=_ \ifdefined\supersubmode \else \newcount\supersubmode \fi \ifdefined\newevery \else \everysupersub \EverySuperSub \fi \appendtoks \advance\supersubmode \plusone \to \everysupersub \setuptextformulas [\c!size=\v!normal] \def\normalsupsub#1#2% {^{\the\everysupersub#1}_{\the\everysupersub#2}} \def\super#1{^{\the\everysupersub#1}} \def\suber#1{_{\the\everysupersub#1}} \def\supsub#1#2{\super{#1}\suber{#2}} \def\subsup#1#2{\suber{#1}\super{#2}} %D \macros %D {enablesupersub,enablesimplesupersub} %D %D We can let \type {^} and \type {_} act like \type {\super} %D and \type {\sub} by saying \type {\enablesupersub}. \bgroup \catcode`\^=\@@active \catcode`\_=\@@active \gdef\enablesupersub {\catcode`\^=\@@active \def^{\ifmmode\expandafter\super\else\expandafter\normalsuper\fi}% \catcode`\_=\@@active \def_{\ifmmode\expandafter\suber\else\expandafter\normalsuber\fi}} \egroup %D \macros %D {restoremathstyle} %D %D We can pick up the current math style by calling \type %D {\restoremathstyle}. \def\restoremathstyle {\ifmmode \ifcase\supersubmode \textstyle \or \scriptstyle \else \scriptscriptstyle \fi \fi} %D These macros were first needed by Frits Spijker (also %D known as Gajes) for typesetting the minus sign that is %D keyed into scientific calculators. % This is the first alternative, which works okay for the % minus, but less for the plus. % % \def\dodoraisedmathord#1#2#3% % {\mathord{{#2\raise.#1ex\hbox{#2#3}}}} % % \def\doraisedmathord#1% % {\mathchoice % {\dodoraisedmathord5\tf #1}% % {\dodoraisedmathord5\tf #1}% % {\dodoraisedmathord4\tfx #1}% % {\dodoraisedmathord3\tfxx#1}} % % \def\negative{\doraisedmathord-} % \def\positive{\doraisedmathord+} % % So, now we use the monospaced signs, that we also % define as symbol, so that they can be overloaded. \def\dodoraisedmathord#1#2#3% {\mathord{{#2\raise.#1ex\hbox{#2\symbol[#3]}}}} \def\doraisedmathord#1% {\mathchoice {\dodoraisedmathord5\tf {#1}}% {\dodoraisedmathord5\tf {#1}}% {\dodoraisedmathord4\tx {#1}}% {\dodoraisedmathord3\txx{#1}}} \def\dodonumbermathord#1#2% {\setbox\scratchbox\hbox{0}% \mathord{\hbox to \wd\scratchbox{\hss#1\symbol[#2]\hss}}} \def\donumbermathord#1% {\mathchoice {\dodonumbermathord\tf {#1}}% {\dodonumbermathord\tf {#1}}% {\dodonumbermathord\tx {#1}}% {\dodonumbermathord\txx{#1}}} \definesymbol[positive] [\getglyph{Mono}{+}] \definesymbol[negative] [\getglyph{Mono}{-}] \definesymbol[zeroamount][\getglyph{Mono}{-}] \def\negative {\doraisedmathord{negative}} \def\positive {\doraisedmathord{positive}} \def\zeroamount{\donumbermathord{zeroamount}} %D How negative such a symbol looks is demonstrated in: %D $\negative 10^{\negative 10^{\negative 10}}$. \protect \endinput