On Dec 22, 2007 9:10 AM, Shen Chen wrote:
Hi all,
I have some chemical formulae in chapter heading and figure captions, typeset with the chemic module. The chemic module always uses roman font as desired.
When I include them in table of contents and list of figures, the chemical formulae appears in math italic font instead of roman font. See the following code for example. Chemic Manual mentioned using \rm but it doesn't seem to be the case. $\rm H_2O$ works fine in the list, but not \chemical{H_2O}. Any suggestions? Thank you.
\usemodule[chemic] \starttext
\writetolist[chapter]{}{ABC} \writetolist[chapter]{}{$H_2O$} \writetolist[chapter]{}{$\rm H_2O$} \writetolist[chapter]{}{\chemical{H_2O}} \completecontent
\stoptext
The code is too complex for me to be able to understand what's going on (but it seems like a problem which should be fixed, I agree). I'm using an "ugly" piece of code from the wiki instead of the module http://wiki.contextgarden.net/Chemistry (bottom of the page) when I need to typeset simple chemistry. I also needed a formula to apear in titiles and it worked really nice. Mojca % by Taco \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} \molecule{H_2O}