# How do I align labelled math expressions along the math axis?

I have a bunch of formulæ and diagrams that I want to present in an alignment with some labels below. Each item is a somewhat complicated formula with different height and depth, something like this:

\halign{\hfil#\hfil&&\quad\hfil#\hfil\cr \vrule width 8em height 8em&\left(\matrix{1&2&3\cr 2 1 3}\right)&X\cr \noalign{\vskip1em} a=123&b=456&c=789\cr}


where \vrule stands for some diagram. However, if I do this, the items are not vertically centered within their cells. I could add \vfil into the cells, but then the items would only be aligned respective to their bounding boxes, not to the mathematical axis. Is there any way to align the cell entries in a line so they are all aligned to the same math axis?

I applied $\vcenter{\hbox{\vrule width 8em height 8em}}$ to the rule (image).

\documentclass{article}
\begin{document}

\halign{\hfil#\hfil&&\quad\hfil#\hfil\cr \vcenter{\hbox{\vrule width 8em height 8em}}&\left(\matrix{1&2&3\cr 2 1 3}\right)&X\cr \noalign{\vskip1em} a=123&b=456&c=789\cr}
\end{document}


• And that works? I'm surprised! – FUZxxl Oct 4 '17 at 12:01
• @FUZxxl It is what \vcenter was designed for...centering things (in particular, a box) about the math axis. – Steven B. Segletes Oct 4 '17 at 12:03
• I was damn sure that every table cell would have a separate math axis and thus look misaligned. – FUZxxl Oct 4 '17 at 12:08
• @FUZxxl Across all the columns of a given table row, a baseline (and thus a math axis) is shared. This may not always be obvious, once the cell contains a macro that adjusts vertical placement, such as \parbox, minipage, or anything that takes a [b], [c], or [t] modifier. – Steven B. Segletes Oct 4 '17 at 12:14
• Good thing these macros don't exist in Plain TeX /s – FUZxxl Oct 4 '17 at 12:45

Take your time to define useful macros that relieve you from the burden of doing repeatedly the same thing.

Here \xeqalign is modeled on \eqalign:

\catcode@=11
\def\xeqalign#1{%
\null\vcenter{\openup\jot\m@th
\ialign{\hfil$\displaystyle{##}$\hfil&&\quad\hfil$\displaystyle{##}$\hfil\crcr#1\crcr}%
}%
}
\def\vcen#1{%
\vcenter{\hbox{$\m@th\displaystyle{#1}$}}%
}
\catcode@=12

\openup2\jot \xeqalign{ \vcen{\vrule width 8em height 8em}& \pmatrix{1&2&3\cr 2 1 3}&X\cr a=123&b=456&c=789\cr }

\bye