The TeXbook defines in chapter 24 (page 270 in my edition) the notion of <dimen>, <skip>, <mudimen> and <muskip>, the first two being used in horizontal and vertical mode, while the other ones are used in math mode.

However this parallel between math mode and other modes is broken by registers: only \dimendef, \skipdef and \muskipdef exist, and not \mudimendef. Similarly, \dimen 0, \skip 0 and \muskip 0 exist, but not \mudimen 0.

The only primitive that manipulates mudimens seems to be \mkern. Why are <mudimens> so special?

EDIT: extra question. I'm asking this because I try to be able to grab the argument of any primitive. To grab a <dimen>, for instance, one can use \newdimen\MyDimen and \afterassignment\DoSomethingWithMyDimen \MyDimen=. Given that TeX does not have <mudimen> parameters, I cannot use the same trick for that. I cannot use a muskip either, because it may mistakenly grab a stretch or shrink part which \mkern would stop at. It may be that I can use a \count register in some cases, but not all: how could I distinguish between cases like \mkern 1mu and \mkern \MyMuskip (with automatic coercion)?

  • 7
    There is only one unit mu for \mkern. Thus a \count would suffie. I guess this is why there isn't \mudimen register. – Leo Liu Aug 13 '11 at 4:57
  • @Leo Liu: that's a great reason. How could I then grab a <mudimen> argument? Can you think of a way to grab exactly what \mkern would grab as its argument? See edit. – Bruno Le Floch Aug 13 '11 at 11:59
  • I've no idea. But I guess you can change your desired syntax and use a count register without problems. – Leo Liu Aug 13 '11 at 15:19
  • @Leo Liu: I'm reading arbitrary TeX code, and expanding fully all macros, then looking at whatever primitive is in front of me and doing what TeX would do with it. So I can't really change my syntax since it's that of TeX. I think I'll settle down for a muskip, despite the fact that it can in some cases grab too much. – Bruno Le Floch Aug 13 '11 at 19:56

Well, the answer is that there's no \mudimen register. :) So there can't be a \mudimendef command. Why Knuth didn't provide this kind of register, I don't know; but probably because \mkern and \mskip are not used so much that different registers for them are needed.

The chances to find \mkern 3mu plus in a document are, I believe, infinitesimal, but you can always test for plus after the specification, in case of \mkern.

There's no coercion either: \mkern 3pt is illegal, just like \mkern 33. In e-TeX there are \mutoglue and \gluetomu to do calculations (with \glueexpr) or comparisons (with \ifdim), but they simply transform 1mu into 1pt or vice versa. And code such as \ifdim\mutoglue\mymuskip>\mydimen is nonsensical, although legal.

For \mkern you could use \afterassignment\DoSomethingForMKern\tempmuskip=, but this, as you observe, will gobble a plus or minus part that might be hidden in a macro, but would stop the argument to \mkern, while the original token list would already be lost. Alas, I don't think it's really possible to do more than this.

  • I can't test anything after the specification: the key with using \afterassignment is that I was letting TeX read tokens itself. Imagine parsing \mkern\muskip\count\dimexpr 1pt/(\dimen0+3)\relax... that's legal: \dimen0 is coerced to an integer, added to 3, divides 1pt to give a value for \dimexpr...\relax, which in turn is coerced to an integer, hopefully small enough to be the number of a \count register, containing the value of the \muskip register to use (and coerce). Quite unfeasible :). – Bruno Le Floch Aug 13 '11 at 21:34
  • +1 for mentionning \mutoglue, and friends, though you could add \muexpr. Besides, I guess that \mutoglue was introduced precisely for use in \ifdim and the like. – Bruno Le Floch Aug 13 '11 at 21:37

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.