# Determining the height of the current line, especially in displayed math

Is there a way to determine the height of the current line? More specifically, after the hbox comprising the current line is finalized, I'd like to determine it's height (and perhaps also depth) and write this information to an auxiliary file. The application I have in mind is placing something in the margin which is vertically aligned with the center of the current line, rather than with the baseline of the current line. I'm primarily interested in the case where the current line is a displayed equation.

(This is a more focused version of this older question.)

-

There is some discussion along these lines in the TeXbook, appendix D (dirty tricks). For example, set \vsize very small so the lines get sent one at a time to the output routine, which can process them and then send them back to the page builder for regular processing (with a normal value of \vsize this time). Or, more close to your question, have the output routine write out notes to a file in a first pass, and process those notes on a second pass.

-

Unfortunately I don't know how to answer your more general question, but it sounds as if the marginnote package will help with the problem that motivated it. By using the \marginnote command in conjunction with its <voffset> option you can manually change to vertical alignment of the margin note arbitrarily. For example, the margin note in the following example is vertically aligned with the equation:

\documentclass{article}
\usepackage{marginnote}
\begin{document}
Here is some text.
$F(b)-F(a) = \int_a^b f(x)dx \marginnote{A form of the fundamental theorem of calculus}[-2em]$
Here's a little more text.
\end{document}

-
Thanks. I've already written a specialized numbers-in-the-margins package that does most of what I want. Manual vertical adjustment was my fall-back strategy, but I was hoping for something that would work automatically. The code for the marginnote package should be useful, in any case. – Kevin Walker Aug 2 '10 at 21:30