Why do I need a '\vspace{0pt}` to align a table and a figure along the bottom line when using '\vbox' and '\hbox'?

A fundamental concept for understanding box placement is that of reference point. Each box has one, and also other items define one.

What TeX processes when typesetting are lists of items. You're mainly interested in vertical lists, where TeX just piles up horizontal boxes and vertical space items (plus other things that are not so relevant here). Between hboxes some glue (vertical spacing) can be inserted automatically by TeX to ensure equidistance between the reference points of these.

What's the reference point of an hbox? It's just the same: every box (or character inside) has one and TeX usually puts together these boxes so that their reference points are on the same horizontal line. However some of them may be shifted vertically: this is the case of the box that results from

\begin{tabular}{<arg>}
<tabular content>
\end{tabular}

whose reference point lies midway from the top to the bottom of the typeset tabular.

If a rule (or an image) is not shifted (which requires manual intervention by the user) its reference point is the lower left corner.

The reference point of a \vbox is the one of the last item inside it. It follows that saying \vbox{\vbox{...}} is just the same as \vbox{...}.

Your first example
The reference points of the two boxes are on the same horizontal line (remember that the "tabular box" has its reference point in the middle).

Your second example
The reference points of the two boxes are on the same horizontal line:

\mbox{}% to ensure horizontal mode
\vbox{\vbox{\hbox{\usebox{\firstfig}}\vspace{0pt}}}
\vbox{\vbox{\hbox{\usebox{\secondfig}}}}

can be reduced to

\mbox{}% to ensure horizontal mode
\vbox{\usebox{\firstfig}\vspace{0pt}}
\usebox{\secondfig}

and in the \vbox the last item is a spacing item, that defines as reference point its bottom.

Your third example
Again the boxes are aligned with respect to their reference points:

\mbox{}% to ensure horizontal mode
\vbox{\vbox{\hbox{\usebox{\thirdfig}}}}
\vbox{\vbox{\hbox{\usebox{\secondfig}}}}

is equivalent to

\mbox{}% to ensure horizontal mode
\usebox{\thirdfig}
\usebox{\secondfig}

because the enclosing boxes do not do anything that changes the reference point position. The boxes contain rules, whose reference point is the lower left corner.

How to get automatically bottom alignment

If you say

\savebox{\firstfig}{%
  \begin{tabular}[b]{ l c r }
    \hline
    1 & 2 & 3 \\
    4 & 5 & 6 \\
    7 & 8 & 9 \\
    \hline
  \end{tabular}
}

(notice the optional argument [b] to \begin{tabular}) the tabular will have its reference point at the bottom item inside it, that is, the \hline. Thus

\usebox{\firstfig} \usebox{\secondfig}

will do what you're looking for without the need to enclose things in an outer \vbox.

Top alignment

Top alignment is slightly harder, but not impossible. With

\savebox{\firstfig}{%
  \begin{tabular}[t]{ l c r }
    \hline
    1 & 2 & 3 \\
    4 & 5 & 6 \\
    7 & 8 & 9 \\
    \hline
  \end{tabular}
}

the reference point of \firstfig will be the top \hline; so what you need is to shift down \secondfig:

\usebox{\firstfig}
\raisebox{-\height}{\usebox{\secondfig}}

but the second box will be slightly lower than the first one, because the reference point is the bottom of the \hline, which has a thickness. With the calc package one can adjust for it:

\usepackage{calc} % in the preamble

\usebox{\firstfig}
\raisebox{-\height+\arrayrulewidth}{\usebox{\secondfig}}

Final remark

The package adjustbox by Martin Scharrer lifts many of these problems, providing very easy methods for modifying the reference point and the alignment of the objects.


The reason is that the tabular has some depth, i.e. it propagetes under the baseline. If you change it to

  \begin{tabular}[b]{ l c r }

you get what you want, because with the [b] flag, the tabular is aligned above baseline (b for baseline at the Bottom).

The command \vspace{0pt} makes it work because it makes the baseline of the whole box to be below the table, at the place of this \vspace.