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

Mojca Miklavec mojca.miklavec.lists at gmail.com
Sat Jul 1 21:24:52 CEST 2006

On 7/1/06, Taco Hoekwater wrote:
> 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

OK. I thought so :(

> >
> > 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.

emm ... I didn't think about that. And I don't notice any big
difference on the monitor to be honest. I'll use endash, but it
doesn't really matter that much.

> > 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.

Didn't work in titles either (or I did something strange) :(
But If I write a couple of explicit \lohi-s, it will still be OK.

> 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.

I don't need that perfect solution. The way it is now is already great.

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

I may not bother about it - I can't redesign the font and I'll worry
about switching to some other font at the end if necessary, now it's
time to concentrate on content. (A pitty that Knuth wasn't a chemist
as well. The chemists would desperately need something similar for
chemistry what TeX offers for mathematics.)

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

I didn't really understand the \iffluor-part of the code ... but don't
bother too much.

Thanks a lot for the trickery again (I'm still impressed by the
\uppercase part),

More information about the ntg-context mailing list