Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sub/superscripts on the left: is this correct?

53 views
Skip to first unread message

Michele Dondi

unread,
Dec 17, 2000, 12:12:31 PM12/17/00
to
Hi all,
I wrote the following macros for placing subscripts and exponents on
the left of their argument:

%%% Begin
\newcommand{\lfput}[2]{%
\@mathmeasure4\expandafter\@firstofone{\copy\tw@#1}%
\@mathmeasure6\expandafter\@firstofone{#2}%
\dimen@-\wd6 \advance\dimen@\wd4
\hbox to\dimen@{}\mathop{\kern-\dimen@\box4\box6}%
}

\newcommand{\lfup}[2]{\lfput{^{#1}}{#2}}
\newcommand{\lfdn}[2]{\lfput{_{#1}}{#2}}
\newcommand{\lfupdn}[3]{\lfput{^{#1}_{#2}}{#3}}
%%% End

They do work well (for me, at least), yet the question is: are they
correct? In fact I obtained them as a little hack to the code for
AMS's \sideset, but since I'm not sure of what I actually do (for
\lfput only, of course, the other ones are for my convenience), I
would like to know this code can be implemented in a better way of if
it could give problems under some cirumstances.


Thanks,
Michele

Michele Dondi

unread,
Dec 20, 2000, 3:31:28 AM12/20/00
to

Michael J Downes

unread,
Dec 20, 2000, 12:49:54 PM12/20/00
to tech-s...@ams.org
Michele Dondi <bik....@tiscalinet.it> writes:

> I wrote the following macros for placing subscripts and exponents on
> the left of their argument:

...


> They do work well (for me, at least), yet the question is: are they
> correct?

Not entirely: the vertical placement will be wrong if these are applied
to a symbol that is taller than a cap letter.

> \newcommand{\lfput}[2]{%
> \@mathmeasure4\expandafter\@firstofone{\copy\tw@#1}%

^^^^^^^^^^^^^^^^^^^^^^^^

I cannot imagine why you want to use this here. It does not do anything
useful, although apparently it evaporates without doing any real harm.
After the box number, \@mathmeasure expects to find \scriptstyle or one
of the other math style commands. (See amsmath.dtx.)

Javier Bezos posted a definition for \roundscripts some months ago to the
comp.text.tex newsgroup. I imagine you could still find it through Deja
News.

Nevertheless I did some further experiments with the idea of using
\@mathmeasure and came up with the following definition for a \prescript
command. Please give it a try and let me know if you find any cases
where it fails to work properly. I guess I could probably release a
small package with this definition if it works well enough.

========================================================================
\documentclass{article}
\usepackage{amsmath}% provides \@mathmeasure

\makeatletter
\DeclareRobustCommand{\prescript}[3]{%
\@mathmeasure\z@\scriptstyle{#1}% put the sup in box 0
\@mathmeasure\tw@\scriptstyle{#2}% put the sub in box 2
\ifdim\wd\tw@>\wd\z@
\setbox\z@\hbox to\wd\tw@{\hfil\unhbox\z@}%
\else
\setbox\tw@\hbox to\wd\z@{\hfil\unhbox\tw@}%
\fi
% Do not let a preceding mathord symbol approach without any
% intervening space.
\mathop{}%
% Use \mathopen to suppress space between the prescripts and the
% base object even when the latter is not of type ord.
\mathopen{\vphantom{#3}}^{\box\z@}_{\box\tw@}%
#3%
}
\makeatother

\begin{document}

\noindent Testing the prescript command.
\[
{}^{4}_{12}\mathbf{C}^{5+}_{2}\quad
\prescript{14}{2}{\mathbf{C}}^{5+}_{2}\quad
\prescript{4}{12}{\mathbf{C}}^{5+}_{2}\quad
\prescript{14}{}{\mathbf{C}}^{5+}_{2}\quad
\prescript{}{2}{\mathbf{C}}^{5+}_{2}
\]
That was produced by
\begin{verbatim}
{}^{4}_{12}\mathbf{C}^{5+}_{2}\quad
\prescript{14}{2}{\mathbf{C}}^{5+}_{2}\quad
\prescript{4}{12}{\mathbf{C}}^{5+}_{2}\quad
\prescript{14}{}{\mathbf{C}}^{5+}_{2}\quad
\prescript{}{2}{\mathbf{C}}^{5+}_{2}
\end{verbatim}

\end{document}

0 new messages