Consider the following code:



    \parbox[t]{\textwidth}{Line 1\\Line 2\\Line 3\\Line 4}



Address box height: \printlength{\fooboxheight} \uselengthunit{mm} \printlength{\fooboxheight}


\fooboxheight is 7pt / 2mm, much smaller than the height of the \parbox! Why is this? What should I do to get the real height of the \parbox?

Interestingly, if the \parbox is surrounded by a \frame, everything works.


Insert the lines


and all will be clear: The height of \foobox is indeed 6.83331pt just as you have found. The depth, on the other hand, is 36pt. Notice that boxes have height and depth both, as measured from the baseline of the box. In this case, this happens because you use \parbox[t]. If you switch to \parbox[b] things might work more like you expect, at least as far as the height calculation goes. But then, of course, the baseline of the box may not be where you need it to be.


The calc package also provides the commands \totalheightof and \settototalheight, "totalheight" being the sum of height and depth.


It's because of the [t] option. It's sets the official parbox baseline to the baseline of the first line. Therefore the height of the box is the height of the first line. The rest is now part of the official depth.

What you need is the so called totalheight which is height+width. There is no primitive for this, therefore there isn't a \settototalheight. However, if you already have the material inside a savebox you don't need to use these macros anyway, but can use \ht, \dp and \wd to get the height, depth and width of the saved box.

The totalheight can be calculated using the 'calc' package:


or using the eTeX primitive \dimexpr:

  • 1
    Actually, the calc package defines \settototalheight. – lockstep Feb 24 '11 at 15:01
  • @lockstep: Thanks, I didn't know that. I rarely use it since I know about the eTeX primitives and pgfmath. – Martin Scharrer Feb 24 '11 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.