summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/chem-str.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/chem-str.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/chem-str.mkiv82
1 files changed, 56 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/context/base/chem-str.mkiv b/Master/texmf-dist/tex/context/base/chem-str.mkiv
index 6430830f73a..197c13bc6a2 100644
--- a/Master/texmf-dist/tex/context/base/chem-str.mkiv
+++ b/Master/texmf-dist/tex/context/base/chem-str.mkiv
@@ -4,7 +4,7 @@
%D subtitle=Chemistry,
%D author=Hans Hagen,
%D date=\currentdate,
-%D copyright=\PRAGMA]
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
@@ -49,6 +49,8 @@
\unprotect
+\installcorenamespace{chemicalsymbol}
+
\unexpanded\def\setupchemical
{\dosingleempty\dosetupchemical}
@@ -80,16 +82,16 @@
{\dodoubleempty\dodefinechemicalsymbol}
\def\dodefinechemicalsymbol[#1][#2]%
- {\setvalue{\??cm::#1}{#2}}
+ {\setvalue{\??chemicalsymbol#1}{#2}}
-\def\chemicalsymbol[#1]%
- {\getvalue{\??cm::#1}}
+\unexpanded\def\chemicalsymbol[#1]%
+ {\getvalue{\??chemicalsymbol#1}}
% size (small medium big)
-\def\dosetchemicaltext
- {\dosetfontattribute \??cm\c!style
- \dosetcolorattribute\??cm\c!color}
+\unexpanded\def\dosetchemicaltext
+ {\dousestyleparameter\@@cmstyle
+ \dousecolorparameter\@@cmcolor}
\edef\chemicaltoplocation{t}
\edef\chemicalbotlocation{b}
@@ -194,7 +196,7 @@
\ignorespaces}
\appendtoks
- \setbox\chemicalbox\hbox{\raise\MPlly\onebasepoint\box\chemicalbox}%
+ \setbox\chemicalbox\hbox{\raise\MPlly\box\chemicalbox}%
\chemicalwidth \wd\chemicalbox
\chemicalheight\ht\chemicalbox
\chemicaldepth \dp\chemicalbox
@@ -204,7 +206,9 @@
\appendtoks
\edef\chemicalbodyfont{\chemicalparameter\c!bodyfont}%
- \doifnot\chemicalbodyfont\fontbody{\switchtobodyfont[\chemicalbodyfont]}% \fontbody is not expanded (yet)
+ \ifx\chemicalbodyfont\empty
+ \switchtobodyfont[\chemicalbodyfont]%
+ \fi
\getvalue{\??cm:\c!size:\chemicalparameter\c!size}%
% \to \everystructurechemical
\to \everychemical
@@ -269,6 +273,8 @@
\mathematics{#1%
{\strut\hbox \!!spread 2em{\hss\ctxlua{chemicals.inline(\!!bs#2\!!es)}\hss}}%
{\strut\hbox \!!spread 2em{\hss\ctxlua{chemicals.inline(\!!bs#3\!!es)}\hss}}}%
+% {\strut\hbox \!!spread 2em{\hss#2\hss}}%
+% {\strut\hbox \!!spread 2em{\hss#3\hss}}}%
\enspace}
% special macros (probably needs some more work)
@@ -278,7 +284,7 @@
\setbox0\hbox{\tx\setstrut\strut#3}%
\setbox2\hbox{\setstrut\strut\molecule{#4}}%
\setbox0\hbox{\raise\dimexpr\dp0+\ht2\relax\hbox to \wd2{#1\box0#2}}%
- \smashbox0
+% no: \smashbox0
\hbox{\box0\box2}%
\endgroup}%
@@ -287,7 +293,7 @@
\setbox0\hbox{\tx\setstrut\strut#3}%
\setbox2\hbox{\setstrut\strut#4}%
\setbox0\hbox{\lower\dimexpr\dp2+\ht0\relax\hbox to \wd2{#1\box0#2}}%
- \smashbox0
+% no: \smashbox0
\hbox{\box0\box2}%
\endgroup}%
@@ -337,7 +343,7 @@
\let\chemicalsmashedright \chemicalrightcentered
\unexpanded\def\chemicaloxidation#1#2#3%
- {\chemicaltop{\txx\ifcase#2\relax0\else#1\uppercase\expandafter{\romannumeral#2}\fi}{#3}}
+ {\chemicaltop{\txx\ifcase#2\relax0\else#1\convertnumber{I}{#2}\fi}{#3}}
\unexpanded\def\chemicaloxidationplus {\dotriplegroupempty\chemicaloxidation{\textplus }} % {} needed!
\unexpanded\def\chemicaloxidationminus{\dotriplegroupempty\chemicaloxidation{\textminus}} % {} needed!
@@ -487,27 +493,51 @@
\unexpanded\def\formulachemical
{\relax\dotriplegroupempty\doformulachemical}
+% \def\doformulachemical#1#2#3% we could do hboxes and measure
+% {\ifthirdargument
+% \doifelsenothing{#2}\noformulachemicaltop{\doformulachemicaltop{#2}}%
+% \doifelsenothing{#3}\noformulachemicalbot{\doformulachemicalbot{#3}}%
+% \else\ifsecondargument
+% \noformulachemicaltop
+% \doifelsenothing{#2}\noformulachemicalbot{\doformulachemicalbot{#2}}%
+% \else
+% \noformulachemicaltop
+% \noformulachemicalbot
+% \fi\fi
+% \formulachemicalmid\expandafter{\the\formulachemicalmid\dodochemicalformulamid{#1}&}}
+%
+% \def\dodochemicalformulamid#1%
+% {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname
+% \csname\??chemicalsymbol\detokenize{#1}\expandafter\endcsname{}{}%
+% \else
+% \molecule{#1}{}{}%
+% \fi}
+
+\def\domidformulachemical#1%
+ {\csname\??chemicalsymbol\detokenize{#1}\endcsname}
+
\def\doformulachemical#1#2#3% we could do hboxes and measure
- {\ifthirdargument
- \doifelsenothing{#2}\noformulachemicaltop{\doformulachemicaltop{#2}}%
- \doifelsenothing{#3}\noformulachemicalbot{\doformulachemicalbot{#3}}%
- \else\ifsecondargument
- \noformulachemicaltop
- \doifelsenothing{#2}\noformulachemicalbot{\doformulachemicalbot{#2}}%
+ {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname
+ \formulachemicalmid\expandafter{\the\formulachemicalmid\domidformulachemical{#1}{#2}{#3}}%
\else
- \noformulachemicaltop
- \noformulachemicalbot
- \fi\fi
- \formulachemicalmid\expandafter{\the\formulachemicalmid\dodochemicalformulamid{#1}&}}
+ \ifthirdargument
+ \doifelsenothing{#2}\noformulachemicaltop{\doformulachemicaltop{#2}}%
+ \doifelsenothing{#3}\noformulachemicalbot{\doformulachemicalbot{#3}}%
+ \else\ifsecondargument
+ \noformulachemicaltop
+ \doifelsenothing{#2}\noformulachemicalbot{\doformulachemicalbot{#2}}%
+ \else
+ \noformulachemicaltop
+ \noformulachemicalbot
+ \fi\fi
+ \formulachemicalmid\expandafter{\the\formulachemicalmid\molecule{#1}&}%
+ \fi}
\def\noformulachemicaltop {\formulachemicaltop\expandafter{\the\formulachemicaltop&}}
\def\noformulachemicalbot {\formulachemicalbot\expandafter{\the\formulachemicalbot&}}
\def\doformulachemicaltop#1{\formulachemicaltop\expandafter{\the\formulachemicaltop\dodochemicalformulatop{#1}&}\settrue\formulachemicalhastop}
\def\doformulachemicalbot#1{\formulachemicalbot\expandafter{\the\formulachemicalbot\dodochemicalformulabot{#1}&}\settrue\formulachemicalhasbot}
-\def\dodochemicalformulamid#1%
- {\ifcsname\??cm::\detokenize{#1}\endcsname\csname\??cm::\detokenize{#1}\expandafter\endcsname\else\molecule{#1}\fi{}{}}
-
\def\dodochemicalformulatop#1{\strut#1}
\def\dodochemicalformulabot#1{\strut#1}
@@ -527,7 +557,7 @@
\c!right=0,
\c!top=0,
\c!bottom=0,
- \c!bodyfont=\the\bodyfontsize,
+ \c!bodyfont=,
\c!scale=\v!medium,
\c!size=\v!medium,
\c!textsize=\v!big,