* Prescript in ConTeXt
@ 2007-04-18 20:03 Aditya Mahajan
2007-04-18 20:49 ` Aditya Mahajan
0 siblings, 1 reply; 3+ messages in thread
From: Aditya Mahajan @ 2007-04-18 20:03 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi Hans and Taco,
I want a command for writing prescript, something that works like
${}^1 f_t$ but with correct spacing. As far as I know, such a command
does not exist in ConTeXt. A bit of a search shows that the "best"
definition in LaTeX is by Michael J. Downes
http://groups.google.com/group/comp.text.tex/msg/49206d0dffe71236?dmode=source&hl=en
This is very similar to \lohi[left] but defined for math mode and
takes care of math spacing.
\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%
}
To port it to ConTeXt, I need something equivalent to \@mathmeasure,
which is defined in amsmath.
% \begin{macro}{\@mathmeasure}
% The function |\@mathmeasure| takes three arguments; the third arg
% is typeset as a math formula in an hbox, using arg |#2| as the
% mathstyle, and the result is left in the box named by the first
% arg. It is assumed that we are already in math mode, so we can turn
% off |\everymath| (in particular, |\check@mathfonts|).
% \begin{macrocode}
\def\@mathmeasure#1#2#3{\setbox#1\hbox{\frozen@everymath\@emptytoks
\m@th$#2#3$}}
What is the correct way to define mathmeasure in ConTeXt? I do not
completely understand how math tokens are handled.
Thanks,
Aditya
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Prescript in ConTeXt
2007-04-18 20:03 Prescript in ConTeXt Aditya Mahajan
@ 2007-04-18 20:49 ` Aditya Mahajan
2007-04-19 7:06 ` Taco Hoekwater
0 siblings, 1 reply; 3+ messages in thread
From: Aditya Mahajan @ 2007-04-18 20:49 UTC (permalink / raw)
To: mailing list for ConTeXt users
Actually, I only want a pre superscipt, so the following works for me
\def\presuper#1#2%
{\mathop{}% To prevent preceeding mathord atoms to approach
\mathopen{\vphantom{#2}}^{#1}% To prevent space between prescript
% and next atom.
\kern-\scriptspace% remove the space introduced by superscript
#2}
This is not perfect, especially with characters with large left
"slope" like A. Any suggestions for improving the macro?
Aditya
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Prescript in ConTeXt
2007-04-18 20:49 ` Aditya Mahajan
@ 2007-04-19 7:06 ` Taco Hoekwater
0 siblings, 0 replies; 3+ messages in thread
From: Taco Hoekwater @ 2007-04-19 7:06 UTC (permalink / raw)
To: mailing list for ConTeXt users
Aditya Mahajan wrote:
> Actually, I only want a pre superscipt, so the following works for me
>
> \def\presuper#1#2%
> {\mathop{}% To prevent preceeding mathord atoms to approach
> \mathopen{\vphantom{#2}}^{#1}% To prevent space between prescript
> % and next atom.
> \kern-\scriptspace% remove the space introduced by superscript
> #2}
>
>
> This is not perfect, especially with characters with large left
> "slope" like A. Any suggestions for improving the macro?
There is no way to fix that automatically, because TeX does not
have 'italic correction' information for the left-side of a glyph.
Best, Taco
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-19 7:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-18 20:03 Prescript in ConTeXt Aditya Mahajan
2007-04-18 20:49 ` Aditya Mahajan
2007-04-19 7:06 ` Taco Hoekwater
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).