Get the latex exit height

I am trying to determine how to get the height for the latex output block (not the whole document and not the code .. but rather the output block). As an example of what I'm trying to achieve: I had to have latex code

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

The height of the above block of text depends on the number of things - the font, the size of the field, and, of course, on the size of the text, since changing any of these parameters changes the number of inches that will be displayed, but with a default value, the formatting of its output will be something like 2 inches tall.

I hope there is a package that does this! I am grateful for any pointers in the right direction!

Thanks in advance!

Georg

+12
latex
source share
2 answers

Usually the trick is to put everything you want to measure in the field, and then just not type the field, but measure it:

 \newdimen\height \setbox0=\hbox{\Huge Hello, World!} \height=\ht0 \advance\height by \dp0 The height is: \the\height 
+11
source share

I think this will work:

 \newlength{\somenamehere} \settoheight{\somenamehere}{\hbox{...}} 

Where ... is your content that you want to measure. And then you can use \somenamehere as the height of this content.


Example:

 \documentclass[english]{article} \usepackage[T1]{fontenc} \usepackage[latin9]{inputenc} \usepackage{babel} \begin{document} \newlength{\heightofhw} \settoheight{\heightofhw}{\hbox{Hello World!}} Value = \the\heightofhw \end{document} 

It will display:

Value = 6.8872pt


Note:

  • Length values ​​are stored as dots, and 1 inch and asympt. 72.27 pt
  • This does not require additional packages.

Update:

Use \hbox to correctly calculate the height of a medium of a different size, but it will not work with newline characters: - (

+10
source share

All Articles