# [XeTeX] Combined sub- and superscript - solved

Sebastian Gerecke sgerecke at l3s.de
Sun Aug 8 09:10:17 CEST 2010

Am Sonntag 08 August 2010, 05:23:27 schrieb Michael Lynch:
> On 07/08/2010 23:32, Ross Moore wrote:
> > Hi Peter, Sebastien,
> >
> > On 08/08/2010, at 7:33 AM, Peter Dyballa<Peter_Dyballa at web.de>
> >
> > wrote:
> >> Am 07.08.2010 um 22:44 schrieb Sebastian Gerecke:
> >>> BUT: This just has to be an utter hack and I can not believe it
> >>> is the way it is supposed to be done.
> >>
> >> This hack is necessary because mhchem is not aware of font
> >> features, it's a simple LaTeX package that maltreats simple TeX
> >> fonts in the usual ways.
> >>
> >>> I'm putting the scientific inferior numbers in the upper
> >>> position, and the scientific superiors in the lower position.
> >>> Does that make sense to anyone?
> >
> > The usual LaTeX way to do this would be to use the \sideset command
> > from AMSMath, that is with \usepackage{amsmath}.
> >
> > But this would be placing the usual ASCII numerals, and not using the
> > Unicode inferior and superior numerals. Those characters are very new
> > to the TeX world. A Google search brings up only a few mentions of
> > them on Microsoft pages. Thus you are not likely to find a good
> > solution having easy syntax, until someone writes a macro specially
> > for it, for use with XeTeX and other Unicode-aware TeX processing.
> >
> > If I've understood this correctly, you want the positioning of
> > \sideset with the characters being the Unicode superiors and
> > inferiors, which are full-sized glyphs. Furthermore, the input syntax
> > should be intuitive, allowing use of either ASCII numerals or the
> > Unicode points directly, for maximum flexibility.
> >
> > Should such support be in the unicode-math package? Probably not, as
> > super-/subscripts in math usually have the usual numerical meaning,
> > so it would be wrong to use separate characters, just for a purely
> > visual effect.
> >
> > Is a chemist going to learn about Unicode and XeTeX just to typeset
> > isotope names correctly? We could be so lucky!
> >
> > However maybe if someone on this list develops such a macro, it could
> > go into xltxtra.sty .
> >
> >> Well, otherwise it would look much worse...
> >
> > Indeed.
> >
> >> -- Mit friedvollen Grüßen
> >>
> >> Pete
> >
> > Hope this helps,
> >
> > Ross
> >
> Hello all,
>
> I don't know anything about \sideset, but does this do what's needed?
>
> \newlength{\atomicwidth}
> \DeclareRobustCommand{\elem}[3]{%
> 	\settowidth{\atomicwidth}{\textsubscript{#2}}%
> 	\textsuperscript{#1}\hspace{-\atomicwidth}\textsubscript{#2}#3
> }
>
> \elem{14}{6}{C}
>
> (I've attached an example file demonstrating it.)
>
> This seems to produce the desired output, is easy to use, and has the
> advantage of playing equally nicely with fonts that don't have the
> required features.
>
> Mike

Hello Mike,

thanks for your code -- it works perfectly :-)
Much better actually than my own solution which is having a problem with
different font sizes.

This really solves my problem. Thanks to everyone your help and attention.

Cheers
Sebastian