## October 5, 2009

### 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.

Posted by distler at October 5, 2009 11:24 AM

TrackBack URL for this Entry:   http://golem.ph.utexas.edu/cgi-bin/MT-3.0/dxy-tb.fcgi/2075

Weblog: Musings
Excerpt: Griping about the JHEP article class.
Tracked: October 6, 2009 12:41 AM

### 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.

Posted by: Urs Schreiber on October 26, 2009 4:12 PM | Permalink | Reply to this

### Re: Fun with (i)tex

Hi, this is a bit off topic.

First of all I recently installed instiki to have a personal wiki to manage my mathematical writings. I am really happy with it and itex2mml!
I have been trying to use Theorems, Corollories etc. like you wrote about here

http://golem.ph.utexas.edu/wiki/instiki/show/Theorems

It doesn’t work for me. I’m not a very computer savvy person, but I have everything up and running so I thought I could do this. Is there anything I need to install to use Theorems etc.?

I apologize if this is not the right place to ask this question.

Best,

Grétar Amazeen

Posted by: Grétar Amazeen on October 27, 2009 3:43 PM | Permalink | Reply to this

### Re: Fun with (i)tex

This is a perfectly fine place to ask questions.

The Theorem support is based on Maruku’s <div> support. Thus, the first thing I would check is that

 +-- {: .un_defn}
###### Definition
foo
=--


produces

 <div class='un_defn'>
<h6 id='definition_1'>Definition</h6>
<p>foo</p>
</div>


in the output, when you view source.

Whether the result looks like what you expect, then depends on some CSS styling, which is handled by Instiki default CSS stylesheet.

Posted by: Jacques Distler on October 27, 2009 3:55 PM | Permalink | PGP Sig | Reply to this

### Re: Fun with (i)tex

Thanks for the help.

When you say view source, do you mean doing “view” and then “page source” in my browser? If so then the output is

###### Definition foo

Posted by: Grétar Amazeen on October 27, 2009 4:12 PM | Permalink | Reply to this

### Re: Fun with (i)tex

Oops
My last comment was supposed to show your first output line, then p in angle brackets around ###### Definition foo and then /div in angle brackets

Posted by: Grétar Amazeen on October 27, 2009 4:17 PM | Permalink | Reply to this

### Re: Fun with (i)tex

Evidently, you are not adhering to the formatting requirements:

1. A line with the characters “+-- {: .un_defn}” (and no spaces at the beginning of the line)
2. A line with the characters “###### Definition” (and no spaces at the beginning of the line)
3. Any number of lines of text
4. A line with the characters “=--” (and no spaces at the beginning of the line)

Clearly, that’s not what you did.

Posted by: Jacques Distler on October 27, 2009 4:32 PM | Permalink | PGP Sig | Reply to this

### Re: Fun with (i)tex

Thank you very much. It’s working now. I found a place where I was putting a space where it shouldn’t have been.

Posted by: Grétar Amazeen on October 27, 2009 6:01 PM | Permalink | Reply to this

Post a New Comment