# box aligned based on top border, but with dynamic width

I want to have a box, aligned based on top border. I can do this with minipage[t], but i would have to specify the width, which i do not want. What is thus the simplest way to have a top-aligned box, with dynamic width?

-
The varwidth package provides varwidth which is exactly like minipage, but shrinks to the natural width of it's contents. Is this what you're after? If not, please provide more detail - perhaps in the form of an image. –  Werner Dec 21 '11 at 7:44

Here is a short example showing the difference between varwidth (from the varwidth package) and other fixed-width boxes like \parbox and minipage:

\documentclass{article}
\usepackage[landscape]{geometry}% http://ctan.org/pkg/geometry
\usepackage{varwidth}% http://ctan.org/pkg/varwidth
\begin{document}
Some text \fbox{\parbox[t]{0.25\textwidth}{in here \rule{5em}{1pt} \par and here}}\
Some text \fbox{\begin{minipage}[t]{0.25\textwidth}in here \rule{5em}{1pt} \par and here\end{minipage}}\
Some text \fbox{\begin{varwidth}[t]{0.25\textwidth}in here \rule{5em}{1pt} \par and here\end{varwidth}}
\end{document}


Note how the width for each box is specified as 0.25\textwidth. However, only the last shrunk down to the natural width of the contents.

Shrinking is a natural process in terms of boxing. Enlarging in a similar context as above is less natural, since one would not know where to start breaking lines.

-
thanks for the hint "varwidth" . –  nicolas roy Dec 21 '11 at 8:36
@nicolasroy: Yes, you need to know what to search for in order to find things - slightly catch-22-ish. :) –  Werner Dec 22 '11 at 19:25