[NTG-context] small caps italic and font switching inside math

Taco Hoekwater taco at elvenkind.com
Sat Jul 1 08:52:37 CEST 2006


Mojca Miklavec wrote:
> 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.)

No it doesn't, it was a leftover from a failed experiment

> 
> Thanks for the magnificent macro! I replaced minus by $-$ and I had to

Does that really look better? You can have bold endashes, but
you will not get a bold minus.

> remove "[left]" because that one is only good for isotopes such as

ah. i misunderstood that.

> It works perfect except in a single case: \title{\molecule{SF_6}}

I had seen that, but not yet bothered to fix it. Still, it is
fairly easy to change the macro, try the version below.

It only moves a lone subscript because i like ions better
if the count and charge are aligned, and I also added an italic
correction. It is possible to get everything looking perfect
(of course), but that would require spending much more time
fine-tuning super- and sub scripts.

Positive ions look absolutely awful in latin modern btw. The
plus from CM is dead-ugly when used in this fashion.


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}

\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 }%


More information about the ntg-context mailing list