I am trying to measure the height of a few lines while the lines are set. I thought the 'real' height of a line is the baselineskip, e.g. 14.5pt for a 12p document. However, when I set the text in vbox to measure its height I get 10.7pt for one line and 25pt for two lines. But should it not be 14.5pt and 29pt, respectively? The MWE below clarifies what I mean.
How do I measure the height of a row as multiples of the height of baselineskip? What I want to achieve is a clear measure of the amount of the number of lines in a box. I thought a clever strategy was to measure the total height and divide over the baselineskip.
\documentclass[12pt]{scrartcl}
\usepackage{lipsum,lmodern,xspace}
\newcommand{\boxheight}[1]{%
\newdimen\height
\setbox0=\vbox{#1}
\height=\ht0 \advance\height by \dp0
#1
}
\begin{document}
\boxheight{\noindent A box with one line is \the\height\xspace high}
\vspace{3ex}
\boxheight{\noindent A box with \\ two lines is \the\height\xspace high}
\vspace{3ex}
\noindent The `real' height of one line is \the\baselineskip.
\end{document}


\newdimenshould be only used once in the preamble, not inside the macro call. Also, the use of\xspaceis not required. Simply use\spaceor\here. – Martin Scharrer Oct 19 '12 at 14:20