Determine height of the line you are in

Is there a way in PDFLaTeX to determine the height of the line you are in? Maybe something similar to PDFsavepos.

In a normal line (i.e. no heading etc.), you might approximate the height by a fixed multiple of ex. But is there a better way?

-
The length \baselineskip may be what you are looking for. – Steven B. Segletes Mar 4 '13 at 20:40
I would suspect this could be done in luaTeX (which I don't know well). Anybody? – mbork Mar 4 '13 at 21:47

Longer answer as noted in comments the current target baseline spacing is \baselineskip so perhaps that is what you are looking for, but if you mean can you determine the height of the current line which may have large inline tables or math expression then it gets harder.

There is no way of having a macro that gives this information at the point that macros expand as an entire paragraph is set (and all macros expanded) before TeX breaks the paragraph into lines and the question has any possible answer.

If you are in a vbox rather than on the main vertical list you can mark the point that you are interested in with \vadjust{\penalty some special value less than -10000} and then \vsplit the box at that point, then look with \lastbox to get the last line box before the forced break, and then looking at the height of that box gives the answer. If the text is on the main vertical list it is a lot harder (you would need a special output routine to take apart and re-assemble the page.

You could use \pdfsaveposition to access the vertical position of the current point on the next latex run, however you can not easily insert this on every line so it isn't clear that you can use this to determine the height of the line at that point.

The following plain TeX file marks two lines (with !) and reports their heights as:

marked line 1: height: 6.94444pt, depth 1.94444pt
marked line 2: height: 12.38954pt, depth 6.14844pt


\tracingonline2

\newcount\linecount
\hsize=3in
\def\a{One two three four five six seven eight nine ten. }

\setbox0=\vbox{\global\linecount=0
\a\a\thislineinfo\a\thislineinfo $A^{^A}A\over B_{B_B}$ \a\a\a

}
\setbox2=\copy0

\immediate\write20{}
\loop
\setbox4=\vsplit2 to \maxdimen
\setbox4=\vbox{\unvbox4\setbox0\lastbox
\immediate\write20{marked line \the\count0: height: \the\ht0, depth \the\dp0}}
\ifnum\count0<\linecount