### Fun with (i)tex

Doubtless, you’re familiar with TeX’s `\rlap{}`

and `\llap{}`

commands. They collapse the bounding box of their content to zero width. The content sticks out of the bounding box (respectively, to the right, or to the left), overlapping the surrounding content. Hence the name…

If, however, you take a look at the code for these commands,

```
\def\llap#1{\hbox to0pt{\hss#1}}
\def\rlap#1{\hbox to0pt{#1\hss}}
```

you notice one unfortunate thing: they don’t work in math mode. That’s a bummer, because they have (or would have) many useful roles in math mode.

In fact, you might even want a `\clap{}`

command, which would collapse the bounding box to zero width, but cause the content to be centered (sticking out equally, both to the left and to the right) about the current point … something like

```
\def\clap#1{\hbox to0pt{\hss#1\hss}}
```

But, of course, that doesn’t work in math mode, either.

Recently, I happened upon this TUGboat article by Alexander Perlis. It explains how to define macros, `\mathrlap{}`

, `\mathllap{}`

and `\mathclap{}`

, which do the same thing as their horizontal mode counterparts, above, but work in math mode.

And I figured out how to implement the same functionality in MathML.

Consider the following commutative diagram.

$\begin{matrix} B^{\mathrlap{A}} & \longrightarrow & 1^{\mathrlap{A}} \\ \mathllap{\scriptsize{\sigma^A}}\downarrow & & \downarrow\mathrlap{\scriptsize{t^\alpha}} \\ P(B)^{\mathrlap{A}} & \underset{\chi_\sigma^A}{\longrightarrow} & P(1)^{\mathrlap{A}} \end{matrix}$

To get the vertical arrows to line up correctly, I used the aforementioned `\mathrlap{}`

and `\mathllap{}`

commands:

```
\begin{matrix}
B^{\mathrlap{A}} & \longrightarrow & 1^{\mathrlap{A}} \\
\mathllap{\scriptsize{\sigma^A}}\downarrow & & \downarrow\mathrlap{\scriptsize{t^\alpha}} \\
P(B)^{\mathrlap{A}} & \underset{\chi_\sigma^A}{\longrightarrow} & P(1)^{\mathrlap{A}}
\end{matrix}
```

(Previously my best attempt, at getting this right, involved games with the `aligned`

environment. This is simpler and better.)

How about `\mathclap{}`

? Look at all the whitespace in
$X = \sum_{1\le i\le j\le n} X_{ij}$

It’s nicer to collapse that whitespace, using

```
X = \sum_{\mathclap{1\le i\le j\le n}} X_{ij}
```

which produces $X = \sum_{\mathclap{1\le i\le j\le n}} X_{ij}$

Anyway, this is all — as you can see — implemented in itex2MML 1.3.13. And, of course, Instiki’s LaTeX export includes the needed macro definitions.

I’m eager for MathML3, which will allow the obvious vertical generalizations, `\mathulap{}`

and `\mathdlap{}`

, to be defined.

## Re: Fun with (i)tex

That’s useful, thanks. I must by now have typed dozens of commuting diagrams into the $n$Lab with badly aligned labeled arrows. Will start using that lap-technology.