3

As I understand it: normally, TeX does not space the same when in text mode, for example, versus script mode. This can be seen in the following example.

Code:

$k-1$ versus $2^{k-1}$

Output:

enter image description here

In the example, the regularly set k-1 is spaced more than when it is in the superscript. Is there a way to force TeX to space in this superscript automatically, i.e. without use of spacing commands such as \;?

3

2 Answers 2

2

In Luatex you can set the spacing used in script style to the same value as used in text style (4mu plus 2mu minus 4mu) however as the superscript is effectively in a box, the stretch and shrink components are not really used, as shown by the second line in each pair here

enter image description here

\documentclass{article}

\begin{document}

$k-1$ versus $2^{k-1}$

$k-1$ versus $2^{k-1}$  A very loose line\linebreak\mbox{}

\typeout{\the\Umathbinordspacing\textstyle}
\typeout{\the\Umathbinordspacing\scriptstyle}
\Umathbinordspacing\scriptstyle=4mu plus 2.0mu minus 4.0mu
\Umathordbinspacing\scriptstyle=4mu plus 2.0mu minus 4.0mu
\typeout{\the\Umathbinordspacing\textstyle}
\typeout{\the\Umathbinordspacing\scriptstyle}


$k-1$ versus $2^{k-1}$

$k-1$ versus $2^{k-1}$  A very loose line\linebreak\mbox{}


\end{document}
0

In the last months, Hans has opened up this in luametatex. With the addition of new math atom classes, spacing in math is now very configurable. I do not think it would be a good idea, however, to define all spaces in scriptstyle to be similar to the ones used in textstyle/displaystyle.

ConTeXt uses luametatex (with some additional classes not defined in the engine). A new muskip \tinymuskip, by default set to 1mu, was defined for the purpose of these kind of spacings, traditionally set tight. (The usual ones are \thinmuskip, \medmuskip and \thickmuskip). But one could in principle define and use several more.

Let us look at an example:

% We show glues
\showmakeup[mathglue]

\starttext
\startTEXpage[offset=1dk]

% This is our testbuffer (\dd gives a d in differential class, with automatically "correct" spacing with other classes)
\startbuffer
$ (k - 1) 2^{k - 1} + (1 + x^2)^{ \int \sin x \dd x } $
\stopbuffer

% This is how it comes out by default
\getbuffer

% This is how it comes out by with no spaces (as in your example)
\start
\tinymuskip 0mu
\getbuffer
\stop


% Here we set the \tinymuskip to something large
% Note that it affects spacing at several places
%    in the exponents
\start
\tinymuskip 6mu plus 1mu minus 1mu
\getbuffer
\stop

% Here we introduce a new muskip
% that we use between ord and bin in scriptstyle.
\start
\newmuskip\mymuskip \mymuskip 12mu plus 2mu minus 4mu
\setmathspacing \mathordinarycode \mathbinarycode \allscriptstyles \mymuskip
\getbuffer
\stop

% Here we set the ordbin space to \medmuskip, 
% the same as it is in textstyle
\start
\setmathspacing \mathordinarycode \mathbinarycode \allscriptstyles \medmuskip
\getbuffer
\stop

\stopTEXpage
\stoptext

This comes out as:

same formula, different spacing

  1. This is the default in ConTeXt, note that there are some tiny spaces inserted around the minus sign and between the x and dx in the superscript.
  2. Here we set \tinymuskip to 0. This is probably the same as you get.
  3. To make the difference more clear, we show one version with a large \tinymuskip
  4. Here we have define a new muskip and uses that between ord and bin (we set it to be pretty large to see the effect. Looks horrible! But if you want to change details, this is the way to go (but with several
  5. If you want the same space (adapting to the size), you can use* \medskip between ord and bin. This will, however, probably result in too much spacing in the sub- and superscripts.

*) In fact, the \allscriptstyles could be changed to \allmathstyles to make it the same for all styles. But, again, it will not look good.

As a final warning, changing the defaults too much will make your math look bad (I've realized this from testing). The default setup of skips, as I understood originally defined by Knuth, have survived for very long, so they cannot be that bad.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.