48

The commands \clap, \llap and \rlap are useful "horizontal" analogues of \smash: they reduce the horizontal width of a box to zero, aligning the box with either the middle, left or right of the typeset contents. Unfortunately they don't work in math mode.

Can someone suggest a math mode macro that has the effect of \clap and friends?

Nils Schmidt
  • 3,423
  • 4
  • 20
  • 13
Scott Morrison
  • 7,553
  • 6
  • 33
  • 32

3 Answers3

45

The mathtools package contains (among other useful things) the implementations of \mathclap and relatives from Andrew's answer.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
  • That should have come up in my search! Strange that it did not. Thanks for filling in. – Andrew Stacey Jul 27 '10 at 11:57
  • I need examples in the use of the clpa command, rlap and llap cause no issues, but I cannot use clap command in the same manner. – Silva Apr 16 '20 at 01:19
13

I don't know if they are implemented in a specific package (search CTAN), but there's an article in TUGBoat, (TUGboat 22 (2001), 350–352.) that gives an implementation. Here's the article on the author's website:

http://math.arizona.edu/~aprl/publications/mathclap/

I suspect that anyone putting this in a package would have used the same names, or at least referred to this article, so searching on CTAN for the command names used there would be a reasonable thing to do.

(Breadcrumb trail: I first learnt of this via this blog post about these commands in iTeX.)

(I'm feeling generous: I just tried the obvious searches on CTAN and nothing came up; so based on that, you should copy the definitions from that article.)

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751
4

FWIW, in ConTeXt \rlap etc do the right thing in math mode as well. They are defined as

\unexpanded\def\rlap{\mathortext\domathrlap\dorlap}
\unexpanded\def\llap{\mathortext\domathllap\dollap}
\unexpanded\def\clap{\mathortext\domathclap\doclap}

where \domathrlap and \dorlap are roughly equivalent to LaTeX's \mathrlap and \rlap.

Aditya
  • 62,301