Skip to main content
4 of 4
more code
David Carlisle
  • 828.7k
  • 74
  • 1.7k
  • 2.6k

within the output routine (which is where I assume you are adding your overlay) you could examine

 \@freelist : List of empty boxes for placing new floats. \@toplist : List of floats to go at top of current column. \@midlist : List of floats in middle of current column. \@botlist : List of floats to go at bottom of current column. \@deferlist : List of floats to go after current column. \@dbltoplist : List of double-col. floats to go at top of current page. \@dbldeferlist : List of double-column floats to go on subsequent pages. 

Or you may prefer to patch

% \begin{macro}{\@flupdates} % \changes{v1.0f}{1993/12/05}{Command added} % This updates everything when a float is placed. % % \begin{macrocode} %<*2ekernel|autoload> \def \@flupdates #1#2#3{% \global \advance #1\m@ne \global \advance \@colnum \m@ne \@tempdima -\ht\@currbox \advance \@tempdima -\ifx #3\@empty \textfloatsep \else \floatsep \fi \global \advance #2\@tempdima \global \advance \@colroom \@tempdima \@cons #3\@currbox } 

so that it updates your data structures in addition to the output routine internals.


Looking at fancyhdr. It uses the first method I suggested. For example it saves \@toplist (in \topfloat) before latex sets the column so that it is still defined at the point that the header is set. Then \iftopfloat does a simple ifx test to see if this is empty.

However if it is not empty then it is a list of (indexes of) box registers that hold the floats that were put at the top of the column. So you can tell how many floats are in that area by the length of the list. However you can't get the extent because by the time the header is called the floats have already been added and the float boxes cleared and recycled.

So this document (which doesn't load any package but uses relevant fancyhdr definitions) can test if there are any top floats and if so count the list and report how many floats are there (0 1 and 2 in this document) but when it iterates over the list to report the sizes of the floats it gets nothing as the boxes have been cleared.

\documentclass{article} \setlength\textheight{20\baselineskip} \raggedbottom \makeatletter \newif\iffootnote \let\latex@makecol\@makecol \def\@makecol{\ifvoid\footins\footnotetrue\else\footnotefalse\fi \let\topfloat\@toplist\let\botfloat\@botlist\latex@makecol} \def\iftopfloat#1#2{\ifx\topfloat\empty #2\else #1\fi} \def\ifbotfloat#1#2{\ifx\botfloat\empty #2\else #1\fi} \def\iffloatpage#1#2{\if@fcolmade #1\else #2\fi} \def\ps@foo{% \def\@oddhead{% T: \iftopfloat{yes [{\count@\z@ \def\@elt{\advance\count@\@ne}\topfloat \the\count@}]% [{\def\@elt{, \the\ht}\topfloat}]% } {no}\hfill}} \pagestyle{foo} \makeatother \def\a{One two three. } \def\b{Red, Green, Blue. } \def\c{\a\a\b\b\a\a\a\b\b\b\a} \def\d{\c\c\par\a\b\c\b\par} \begin{document} \d \begin{figure}[!t] \fbox{XXXXXX} \caption{jjj} \end{figure} \d \begin{figure}[!t] \fbox{XXXXXX} \caption{jjj} \end{figure} \begin{figure}[!t] \fbox{XXXXXX} \caption{jjj} \end{figure} \d \end{document} 

So instead of just using \let to save a snapshot of the latex lists use \edef to save a list which saves the height width and depth of the box. then in the page header you can count the list as before or add up all the heights (plus \floatsep for all but the first) and so report the height of the top float area.

Doing the same for the other areas is left as an exercise:-)

\documentclass{article} \setlength\textheight{20\baselineskip} \raggedbottom \makeatletter \newif\iffootnote \let\latex@makecol\@makecol \def\@makecol{\ifvoid\footins\footnotetrue\else\footnotefalse\fi \def\@elt##1{\noexpand\@elt{\the\ht##1}{\the\dp##1}{\the\wd##1}}% \edef\topfloat{\@toplist}% \let\@elt\relax \let\botfloat\@botlist\latex@makecol} \def\iftopfloat#1#2{\ifx\topfloat\empty #2\else #1\fi} \def\ifbotfloat#1#2{\ifx\botfloat\empty #2\else #1\fi} \def\iffloatpage#1#2{\if@fcolmade #1\else #2\fi} \def\count@elt#1#2#3{\advance\count@\@ne} \def\sum@elt#1#2#3{\advance\dimen@\floatsep\advance\dimen@#1\relax} \def\ps@foo{% \def\@oddhead{% T: \iftopfloat{yes [{\count@\z@ \let\@elt\count@elt \topfloat \the\count@}]% [{\dimen@-\floatsep \let\@elt\sum@elt \topfloat size of top area: \the\dimen@}]% } {no}\hfill}} \pagestyle{foo} \makeatother \def\a{One two three. } \def\b{Red, Green, Blue. } \def\c{\a\a\b\b\a\a\a\b\b\b\a} \def\d{\c\c\par\a\b\c\b\par} \begin{document} \d \begin{figure}[!t] \fbox{XXXXXX} \caption{jjj} \end{figure} \d \begin{figure}[!t] \fbox{XXXXXX} \caption{jjj} \end{figure} \begin{figure}[!t] \fbox{XXXXXX} \caption{jjj} \end{figure} \d \end{document} 
David Carlisle
  • 828.7k
  • 74
  • 1.7k
  • 2.6k