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

Mojca Miklavec mojca.miklavec.lists at gmail.com
Thu Jun 29 04:11:35 CEST 2006

On 6/28/06, Taco Hoekwater wrote:
> Aditya Mahajan wrote:
> > Some catcode trickery might work. This is all I could manage.
> This does not work well, because
>         HSO\low{4}\high{-}
> is not correct.

True, but if I'm aware of it, I can use \lohi{4}{$-$} if needed, which
works even better in some cases, see below. I converted the document
from LaTeX and I didn't came to the idea of using low and high
(perhaps just because that's "not possible" there).

> > % \def\molecule#1{\mathematics{ {\rm #1}}}

Thank you for the note. I would never use it inside formulas, but I
would never though about such interference in more complex definitions

> > \bgroup
> > \catcode`\_=\active
> > \catcode`\^=\active
> > \gdef\activatelohi%
> >    {\catcode`\_=\active
> >     \def_{\low}
> >     \catcode`\^=\active
> >     \def^{\high}}
> >
> > % This does not work. Why?
> > % \gdef\molecule#1{\activatelohi #1}
> (For educational purposes only, it cannot be used by
> Mojca this way because of the staggered scripts)

To be honest: in the particular document I never use any stacking (so
this just perfectly suits my needs) except in one particular case: for
typesetting isotopes.

I completely forgot about the \lohi command which I never saw in
practice until now (at least the command itself is documented, but
there's no example and as can be reconstructed from the archives it
seems that Hans added added the option [left] for usage in chemistry).
Thank you, Hans! In the math mode I would have to use phantoms and
such befere being able to achive the same effect, so something like
$\rm _8^16O$ is "wrong" (ugly) anyway.

Taco and Aditya: thanks a lot for the pointers to \low and \high and
for showing me the trick. I appreciate the elegance of Taco's last
solution, although I would never have come to it (I didn't know that
something like that could work and I'm stil not quite sure what
miracle happens in the last step ;).

> Your macro has already parsed the argument. This way
>    \def\molecule#1{{\activatelohi \scantokens{#1}}}
> it would work (because \scantokens re-evaluates the argument).
> And this way it does not need etex, nor the \gdef:
>    \def\molecule%
>      {\bgroup
>       \catcode`\_=\active \uccode`\~=`\_ \uppercase{\let~\low}%
>       \catcode`\^=\active \uccode`\~=`\^ \uppercase{\let~\high}%
>       \domolecule }%
>    \def\domolecule#1{#1\egroup}

> > I have not looked into it, but doesn't one of context's chem module
> > fit this need?
>    \usemodule[chemic]
>    \let\molecule\chemical
> It only gets the size right, not the boldnes. But it can be argued
> that that is the correct behaviour anyways.

Not so long ago you argued that \alpha-sheet, \beta-helix,
\gamma-rays, ... should  be part of text flow (a reason why the el
companion encoding should have it), not a "mathematical thing". I have
a lot of simple formulas such as \molecule{SF_6} and they look
a-kind-of-ugly with a tiny script.

You could compare it to {\bf How to loose a guy in $10$ days}.

I have a strange feeling that handling fonts in math is rather
limited, but no knowledge how to fix anything (just remembering that I
still don't know how to properly switch to bold math with some other
fancy font except with dirty tricks).

I guess that it should be possible to remember the font before
switching to math and then switch to that font again, but that's all
black magic for me. A site on ConTeXt garden solves that for titles in
such a way that there's an additional command provided which also
appends bold to all the mathematics in titles, but that's useful for
titles only.


More information about the ntg-context mailing list