[texhax] TeX Query 7: measuring the real height and width

Jim Diamond Jim.Diamond at acadiau.ca
Sun Dec 9 13:26:06 CET 2012


On Sun, Dec  9, 2012 at 03:27 (+0000), Paul Stanley wrote:

> Hi folks,
> How does one draw a `virtical' line to a specified length in order to
> measure the height of box or boxes in the output?

> For example, a virtical line to get an idea of the `real' height of
> the following structure:
> %start code
> {\hsize = 5cm \settabs 3 \columns
> \+column 1&column 2&column 3\cr
> \+one&cattle&herd\cr
> \+two&fish&school\cr
> \+three&lions&pride\cr}
> %end code

> There may be other ways of getting the real height and width of boxes
> and compound structures, if so, i'd be grateful for more info.

Paul,

if you say

\setbox0=\vbox{
{\hsize = 5cm \settabs 3 \columns
 \+column 1&column 2&column 3\cr
 \+one&cattle&herd\cr
 \+two&fish&school\cr
 \+three&lions&pride\cr}
}

\showthe\ht0


\showthe\dp0


you will get the height and depth of that construct.

This doesn't draw a vertical line for measuring, but if that was an
indirect method anyway, you might like this better.

If you really want a rule drawn, try this:

\setbox0=\vbox{
{\hsize = 5cm \settabs 3 \columns
 \+column 1&column 2&column 3\cr
 \+one&cattle&herd\cr
 \+two&fish&school\cr
 \+three&lions&pride\cr}
}
\hbox{\vrule  height \ht0 depth \dp0 \box0}


Cheers.
				Jim



More information about the texhax mailing list