# Variable box size from input text

How can I make a framed box such that, when spacing is added in the correct places, the box height is exactly 15 cm? Explicitly, how do I define a \newcommand taking in three inputs {A}{B}{C} and displaying a framed box with the value of x computed from the sizes of A, B and C from below to make the box exactly 15cm:

A
\vspace{x}
B
\vspace{x}
C


As I'm trying to learn one thing at a time, a LaTeX answer is preferred, though feel free to post other solutions!

-

You could use \vfill for filling the space, stretching the content to the full height, such as

\documentclass{article}
\newcommand*{\mybox}[3]{%
\fbox{
\parbox[t][15cm]{\textwidth}{%
#1
\vfill
#2
\vfill
#3
}
}
}
\begin{document}
\noindent
\mybox{A}{B}{C}
\end{document}


I used the optional height argument for \parbox and t for top alignment. Though top alignment is the default, id doesn't work without. The syntax of \parbox with all optional arguments is

\parbox[position][height][inner-pos]{width}{text}


The parbox, which means the inner box, has the desired size. If you would like to have an "outer" height of 15 cm, you could calculate the inner height using the calc package.

\vfill is equivalent to \vspace{\fill} and inserts space that can stretch as much as possible, so filling the parbox. Inserted twice they share the available space equally.

-
So if \vfill's will grow to eat half the space, will n \vfill's always grow to each eat 1/n the space? If so, that is really useful to know! –  Hooked Nov 11 '11 at 14:42
After the first \vfill, shouldn't that be a #2, not a #3? –  Hooked Nov 11 '11 at 14:50
Sure, typo, I correct. –  Stefan Kottwitz Nov 11 '11 at 14:55
You can use \parbox[c][15cm][t]{...} if you want the standard behavior of \parbox as regards alignment and top placement inside. –  egreg Nov 11 '11 at 15:19