I would like a vertical equivalent to \mbox{}
that somehow takes a sequence of boxes and stacks them on top of each other.
I'd like the resulting width to be the width of the widest box, and I'd like it to have the following options:
- either no vertical space between the boxes or standard inter-line spacing
- left, right, or center alignment
-
the baseline of the resulting box goes through one of the following:
- top: the baseline of the first box (like
\vtop
) - middle: in the middle of the box
- bottom: the baseline of the last box (like
\vbox
)
- top: the baseline of the first box (like
For example:
surrounding text
\fbox{\stack[align=rt]{something}{something else}{foo}}
surrounding text
would produce:
+----------------+
surrounding text | something | surrounding text
| something else |
| foo |
+----------------+
Does something like this already exist? If not, does anyone have any pointers about how to make it?
Edit: I'm using LaTeX
Best Answer
The v0.8 of
adjustbox
from 2011/11/14 has now a\stackbox[<hor>][<vert>]{<content>}
macro (and a matchingstackbox
environment andstack
key). It accepts vertical and horizontal alignment and uses thevarwidth
package internally. To remove the usual skip between lines, you can use\baselineskip=0pt
at the begin and\par
at the end. I might add an option for this later.