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
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
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
participants (2)
-
Aditya Mahajan
-
Taco Hoekwater