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:


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

1 Answer 1


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


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


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.

framed box

  • 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, 2011 at 14:42
  • After the first \vfill, shouldn't that be a #2, not a #3?
    – Hooked
    Nov 11, 2011 at 14:50
  • Sure, typo, I correct.
    – Stefan Kottwitz
    Nov 11, 2011 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, 2011 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .