Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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{%
    \dimen@i\topmargin\advance\dimen@i\headheight%
    \advance\dimen@i\headsep\advance\dimen@i 1in%
    \advance\dimen@i\textheight%
    \put(0, -\dimen@i){\line(1,0){2\textwidth}}}
}

\newcount\@cp
\def\copypasta#1#2{\@cp=0\loop\ifnum\@cp<#1 #2\advance\@cp by1\repeat}
\begin{document}
\copypasta{400}{white purple }
\footnote{Oh noes}
\copypasta{200}{brown fox }
\end{document}

Thanks!

share|improve this question
    
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
add comment

1 Answer 1

up vote 1 down vote accepted

Hoisted from comments:

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}
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.