On 6/29/06, Taco Hoekwater <wrote: > > {\bf A test \variant[Caps] in small caps}
Does this work on your computer? (I don't get any caps here.) > \newbox\chemlowbox > \def\chemlow#1% > {\setbox\chemlowbox\hbox{{\switchtobodyfont[small]#1}}} > > \def\chemhigh#1% > {\ifvoid\chemlowbox \high{{\switchtobodyfont[small]#1}}% > \else \lohi[left]{\box\chemlowbox}{{\switchtobodyfont[small]#1}}\fi } > > \def\finishchem{\ifvoid\chemlowbox \else \low{\box\chemlowbox}\fi} > > \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}}}}% > \catcode`\-=\active \uccode`\~=`\- \uppercase{\def~{--}}% > \domolecule }% > > \def\domolecule#1{#1\finishchem\egroup} > > \starttext > > \molecule{HSO_4^{-}} > \molecule{H_2SO_4} > > {\bfa A story about \molecule{SF_6}} > {\scx A story about \molecule{sf_6}} > {\bsb A story about \molecule{SF_6}} > > > \stoptext Thanks for the magnificent macro! I replaced minus by $-$ and I had to remove "[left]" because that one is only good for isotopes such as "_8^16O" (I defined another command for them: they usually don't appear in formulas anyway), \molecule{SO_4^{2+}} would be weird otherwise. It works perfect except in a single case: \title{\molecule{SF_6}} But please do not lose too much time on it. I can still use explicit \high and \low in titles (I didn't think about them before you two reminded me about its existence and I'm very grateful for that). > > i didt follow this thread, so i may be wrong, but doesn't the ppchtex > > (see manuals) module does that kind of stuff? > > It doesn't retain font styles (at least, I could not make it do that) Same here. I first had my own simple definition \def\molecule#1{$\rm #1$}, but I didn't know how to change the font automatically. \chemical{H_2O} is almost the same as the definition above (of course the latter is much more powerful, but I only needed it for very simple formulas). In general it's probably not a good idea to typeset the formulas in bold and/or italic, but that was for some rather "special occasion" (very simple formulas often being part of titles, italic/bold text and so on, ...). Mojca _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context