tags:

views:

67

answers:

2

Hello, I am trying to determine how to get the height on a block of latex output (not the whole document, and not the code..but rather a block of output). As an example of what I am trying to accomplish: i were to have the latex code

$\sum_{i=0}^\infty \frac{1}{n}>\infty$ \newline hello world \newline hello universe

The height of the above block of text is dependent on a number of things-font, margin size, and of course what the text is, as changing any of these parameters changes how many inches that output would be, but with default formatting its output would be something like 2 inches high.

I am hoping there is a package that does this! I am appreciative of any pointers in the right direction!

Thanks in advance!

Georg Raba

+1  A: 
Pindatjuh
+2  A: 

Usually, the trick is to put whatever you want to measure into a box and then simply not typeset the box, but measure it:

\newdimen\height
\setbox0=\hbox{\Huge Hello, World!}
\height=\ht0 \advance\height by \dp0
The height is: \the\height
Kilian Foth
This won't work with \newline. is there a workaround for this, or a different approach?Thanks in advance!georg
georg raba
Oh, right. Sorry. For multiple lines, use `\vbox` (vertical box) instead.
Kilian Foth
this works perfectly. Though, I was wondering where i could find out more about what's going on here.. why do you need \the in \the\height?danke im Voraus!
georg raba
`\the` is a convenient TeX primitive, so the canonical explanation isin the TeXbook, p.214. A nice online explanation is at http://www-f9.ijs.si/~matevz/docs/tex/cseq.html#the-rp.
Kilian Foth