I want to encase a `\begin{align}\end{align}` block in a `\parbox` of exactly the width it takes up. If I try:

```
\settowidth{\alignwidth}{\vbox{\begin{align}
\vec a+\vec b&=(\vec a_x+\vec a_y)+(\vec b_x+\vec b_y) \\
&=(\vec a_x+\vec b_x)+(\vec a_y+\vec b_y) \\
\vec a+\vec b&=(\vec a+\vec b)_x+(\vec a+\vec b)_y
\end{align}}}

```

it just gives a value equal to the full `\textwidth`. I've been able to measure all kinds of things, but align blocks have eluded me, short of measuring the longest line, which is a pain and not very generalisable.

The background is that on one line I want diagram 1, set of equations 1, diagram 2, set of equations 2 and I want it laid out to look the best. So far I'm putting them in four `\parboxes` with total width `\textwidth`.

I use this layout a lot and am trying to automate it as individual tweaking is a pain.

This is just the tip of the iceberg. I am writing a physics book and there are much more complicated figure layouts than this. I have read books where for example, to understand a particular problem, one has to keep in mind a diagram, a table of rules and a derivation which are in three different locations and it just ends up being a painful experience. Combining elements like these into a larger figure which can be read comfortably and presents well is not straightforward at all using standard routines and I have tried many existing packages over the last few years.

Anyway, I now have an answer to my question and have presented it below.

Addendum: Knowing the width of a column of equations is not necessarily an end in itself. Subtract this from `\textwidth` and you have calculated the remaining space on the line, so even if the equations don't need to go in a box, something else that's being assembled on the fly can use that value to determine various element widths to end up with something that's either not too wide on the line or doesn't get pushed onto the next line. There are other scenarios, for example ending with a set of equations to the right of various elements, that needs either multiple equation numbers on various lines or an end of theorem bowtie at the end of the last line, that need to be at the right margin. The exact remaining space enables them to line up perfectly.