Changes

Jump to navigation Jump to search
2,899 bytes added ,  11:51, 2 July 2006
Taco's macros for molecules added
* [[Chromatograms]] macro
* [[manual:xchemml-p.pdf|ChemML]] ([[manual:xchemml-s.pdf|screen]]), [[MathML]] extension for chemistry
 
=== Formulae with chemic module ===
 
<texcode>
\usemodule[chemic]
\chemical{HSO_4^{-}}
</texcode>
 
<context>
\usemodule[chemic]
\chemical{HSO_4^{-}}
</context>
=== Simple Formulae in Text Mode ===
<texcode>
\ss H\low{2}O also consists of H\high{+} and OH\high{$-$-}.
There are two main carbon isotopes: \lohi{6}{12}C and \lohi[left]{6}{13}C.
</texcode>
<context>
\ss H\low{2}O also consists of H\high{+} and OH\high{$-$-}.\crlf
There are two main carbon isotopes: \lohi{6}{12}C and \lohi[left]{6}{13}C.
</context>
 
Taco's macros implement this approach:
 
<texcode>
\newbox\chemlowbox
\def\chemlow#1%
{\setbox\chemlowbox\hbox{{\switchtobodyfont[small]#1}}}
 
\def\chemhigh#1%
{\ifvoid\chemlowbox \high{{\switchtobodyfont[small]#1}}%
\else \/\lohi{\box\chemlowbox}{{\switchtobodyfont[small]#1}}\fi }
 
\def\finishchem%
{\ifvoid\chemlowbox \else
\iffluor \fluorfalse \kern-.1em \fi\low{\box\chemlowbox}\fi}
 
% for "kerning" after F
\newif\iffluor
 
\unexpanded\def\molecule%
{\bgroup
\catcode`\_=\active \uccode`\~=`\_ \uppercase{\let~\chemlow}%
\catcode`\^=\active \uccode`\~=`\^ \uppercase{\let~\chemhigh}%
\dostepwiserecurse {65}{90}{1}
{\catcode \recurselevel = \active
\uccode`\~=\recurselevel
\uppercase{\edef~{\noexpand\finishchem
\rawcharacter{\recurselevel}}}}%
\uccode `\~=`\F \uppercase{\def~{\finishchem F\fluortrue}}%
\catcode`\-=\active \uccode`\~=`\- \uppercase{\def~{--}}%
\loggingall
\domolecule }%
 
\def\domolecule#1%
{\expandafter\scantokens\expandafter
{\detokenize{#1\finishchem}}\egroup}
</texcode>
 
<texcode>
\bs Bold slanted molecules: \molecule{HSO_4^-} and \molecule{SF_6}
</texcode>
 
<context>
\newbox\chemlowbox
\def\chemlow#1%
{\setbox\chemlowbox\hbox{{\switchtobodyfont[small]#1}}}
 
\def\chemhigh#1%
{\ifvoid\chemlowbox \high{{\switchtobodyfont[small]#1}}%
\else \/\lohi{\box\chemlowbox}{{\switchtobodyfont[small]#1}}\fi }
 
\def\finishchem%
{\ifvoid\chemlowbox \else
\iffluor \fluorfalse \kern-.1em \fi\low{\box\chemlowbox}\fi}
 
% for "kerning" after F
\newif\iffluor
 
\unexpanded\def\molecule%
{\bgroup
\catcode`\_=\active \uccode`\~=`\_ \uppercase{\let~\chemlow}%
\catcode`\^=\active \uccode`\~=`\^ \uppercase{\let~\chemhigh}%
\dostepwiserecurse {65}{90}{1}
{\catcode \recurselevel = \active
\uccode`\~=\recurselevel
\uppercase{\edef~{\noexpand\finishchem
\rawcharacter{\recurselevel}}}}%
\uccode `\~=`\F \uppercase{\def~{\finishchem F\fluortrue}}%
\catcode`\-=\active \uccode`\~=`\- \uppercase{\def~{--}}%
\loggingall
\domolecule }%
 
\def\domolecule#1%
{\expandafter\scantokens\expandafter
{\detokenize{#1\finishchem}}\egroup}
 
{\bsx Bold slanted molecules: \molecule{HSO_4^-} and \molecule{SF_6}}
 
</context>
 
The main difference with the official chemic module is that the <code>\modlecule</code> from this example uses the same font as the one in surrounding text, while the official module always uses roman font (which is probably the proper way if you're writing dozens of formulas). Hans's module is also more powerful (can do much more trickery than a simple conversion of subscripts and superscripts). See the manuals listed above.
[[Category:Graphics]]
[[Category:Chemistry]]

Navigation menu