TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was trying to figure out an automatic answer to Sharing alignment between equations in two different items by way of typesetting an {align} inside a \vbox and then using \unvbox and \lastbox repeatedly to get the lines of the alignment. Alas, this does not work, as this session with latex shows:


*\setbox0=\vbox{\begin{align*} a&=b \end{align*}}


> \box0= []

! OK.
<*> \showbox0






> \box1=void

! OK.
<*> \showbox1


How can there be nothing in the box? Doesn't TeX typeset something? This is surely a mathmode thing, except that the following does work:

> tex



> \box0=
.\hbox(0.0+0.0)x469.75499, glue set 449.75499fil
..\penalty 10000
..\glue(\parfillskip) 0.0 plus 1.0fil
..\glue(\rightskip) 0.0
.\penalty 10000
.\glue(\abovedisplayshortskip) 0.0 plus 3.0
.\glue(\baselineskip) 3.5
.\hbox(8.5+3.5)x26.24402, shifted 221.7555
..\glue 1.66663
...\hbox(8.5+3.5)x22.91077 []
..\glue 1.66663

! OK.
<*> \showbox0



(\eqalign is the TeX version of {align}, to some extent). Perhaps it is more that the AMS environments do what the TikZ documentation refers to as "wicked things", but I don't see how they could trick TeX itself into thinking the box were empty. I do notice that even in the \eqalign example, the innermost box of the alignment is \hbox(8.5+3.5)x22.91077 []; going by the dimensions \hbox(0.0+0.0)x469.75499, glue set 449.75499fil, this is the text (i.e. a = b) but the empty brackets indicate that there is nothing inside the box. So maybe it is a mathmode thing after all and the AMS' wickedness is just hiding the surrounding material as well?

So, is there any way to unwrap an {align}?

share|improve this question
In your solution to that question, you use \intertext. amsmath uses \noalign to solve the problem. I think it is the right way. – Leo Liu Oct 13 '11 at 15:32
@Leo: There was a further question, though, about how to align not only between different \items but between different paragraphs. \noalign won't work for that. – Ryan Reich Oct 13 '11 at 16:00
If all else fails, you could always "mark" the alignment places in the PDF, saving them in the aux file, and read in the coordinates on the next TeX run. – Loop Space Oct 13 '11 at 16:07
@Andrew: I was actually considering a TikZ solution to get the coordinates, but I was curious if simply saving the lines one at a time could work. Now I'm just puzzled by the behavior in the question. – Ryan Reich Oct 13 '11 at 16:11

The column width in an align are kept in the macro \maxcolumn@widths that's set after the first pass over the environment's contents: in your case

> \maxcolumn@widths=macro:
-> \or 5.28589pt \or 17.62488pt \or 0.0pt.

One can access to the values with \ifcase. Of course it's necessary to "export" the macro, which can be done by saying in any of the cells


(maybe this can be added to the code for \end{align*}, but I'm not sure).

share|improve this answer
up vote 0 down vote accepted

Turns out that the main thing I was asking about is the result of a misunderstanding: if you set \showboxdepth large enough, then everything will be displayed as expected. No empty boxes.

As for unwrapping an {align}: Presumably some combination of \unskip and \unpenalty will reveal the actual list of lines, after which \lastbox will work. See my second answer to Sharing alignment between equations in two different items for the easy version of this.

share|improve this answer
You can't access the \halign via \lastbox, because align and align* add a final \mathoff node that you can't remove. Unwrapping the \halign must be done before math mode is closed. – egreg Oct 17 '11 at 10:19
@egreg: I knew there was a reason I did it the other way! – Ryan Reich Oct 17 '11 at 15:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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