# What is the height of the footnote, at shipout ?

Suppose I want to draw an horizontal line, at shipout, the position of which is on top of the footnotes if some are in the page, and the bottom of the text otherwise. How can I retrieve the height of the footnote section to do so?

For instance, the following puts a line at the end of the page (footnote included) :

\documentclass{article}
\usepackage{atbegshi}
\usepackage{picture}

\makeatletter
\AtBeginShipout{%
\AtBeginShipoutUpperLeftForeground{%
\put(0, -\dimen@i){\line(1,0){2\textwidth}}}
}

\newcount\@cp
\begin{document}
\copypasta{400}{white purple }
\footnote{Oh noes}
\copypasta{200}{brown fox }
\end{document}


Thanks!

-
A non-answer: \ht\footins tells you how high the footnotes are that are currently queued for insertion, but this doesn't help because (i) some of these may be deferred if there are too many for this page, and (ii) by the time the shipout hook is invoked, the footnotes you are interested in will have been split from this register. But if you could get the difference between the value of \ht\footins before and after the insertions were performed... –  Charles Stewart Sep 8 '10 at 12:27
Charles, thanks for the input. I didn't realize \footins was reset at BegShip. I redefined \output to catch the value before the output is actually done, see : pastebin.com/N48zgbbR . There is still a small delta the origin of which I can't understand, but that's pretty close. Would you put your comment as an answer so that I can validate it? –  Michaël Sep 8 '10 at 16:24

A non-answer: \ht\footins tells you how high the footnotes are that are currently queued for insertion, but this doesn't help because (i) some of these may be deferred if there are too many for this page, and (ii) by the time the shipout hook is invoked, the footnotes you are interested in will have been split from this register. But if you could get the difference between the value of \ht\footins before and after the insertions were performed...

Redefining \output: yes, good idea. In fact, you can avoid messing about with dimensions by putting an \hrule at the top of \box\footins:

\makeatletter
\edef\@@output{\the\output}
\output={\setbox\footins=\vbox{\hrule width 2in\unvbox\footins}
\@@output}

-
I can't make your last comment to work, but thanks! Oh, and could you by any chance point the place (maybe in the TeXbook) where the deferring (in case of too-many footnotes) takes place? –  Michaël Sep 8 '10 at 18:54
(Managed to get it working with \output={ \ifvoid\footins\else \setbox\footins\vbox{\hrule width 2in\unvbox\footins} \fi \@@output}, Thanks!) –  Michaël Sep 8 '10 at 19:00
This seems like a good solution. See also Chapter 23: Output Routines page 256. There are some gems there! –  Yiannis Lazarides Sep 8 '10 at 19:17
@Michaël: Fixed the code. You don't need \ifvoid - if the box is empty, \unvbox does nothing. Chapter 28, 'Output Routines', of Tex by Topic covers this material. –  Charles Stewart Sep 9 '10 at 6:55
Thanks! (Though I still fail to compile it, as it falls in a seemingly infinite loop of Overfull \vboxes -- but it's probably time I do something by myself :-)) –  Michaël Sep 9 '10 at 16:30