How do I make a bottom float replace the footer?

I have a \begin{figure*}[b!]. It correctly floats to the bottom of the page, but the page still has the footer below it. (It is a figure spanning two columns of an otherwise multicol-2 document.) I would like the figure to replace the footer - currently a page number and section names, set with fanyhdr - so that it uses all available space till the bottom of the page, and more space is left for the main text above it.

What is the best way to accomplish that? I would like to keep the "float" aspect of the figure, so this replacement happens automatically on the correct page the figure is placed.

Edit: the following MWE should be "fixed" by only adding code to \replaceFooterFig.

\documentclass{book}

\usepackage{lipsum}
\usepackage{multicol}
\usepackage{color}

\usepackage{geometry}
\geometry{a5paper,textwidth=132mm,textheight=190mm}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\thepage}

\newcommand{\replaceFooterFig}[1]{% all necessary code goes here
\begin{figure*}[b!]
\color{red}#1
\end{figure*}
}

\begin{document}

\begin{multicols}{2}

\lipsum[1-10]

\replaceFooterFig{
I should replace the footer (no gap to page border, multicols above makes use of the additional space!).
\lipsum[1]
}

\lipsum[11-20]

\replaceFooterFig{
I am shorter, but I should replace the footer, too.
\lipsum[2]
}

\lipsum[21-30]

\end{multicols}

\end{document}

• Interesting question, it's probably accomplishable, but I can't look into it now, unfortunately :( – yo' May 4 '16 at 13:20
• I made some experiments/hacks with raiseboxex, and while it is possible to move the figure this way, the main body above won't use the additional space. Manually disabling the footer for the page is cumbersome, as the float might shift a page now and then when main content is changed. – TeXter May 4 '16 at 14:19
• Can you add a MWE to give use something to play with? – samcarter is at topanswers.xyz May 9 '16 at 15:39
• Done. Creates a red footer on page 3 and 5 on a two-col document. – TeXter May 9 '16 at 17:40

Here, I modify \replaceFooterFig to do several things. It puts the figure into a saved \vbox. It then diminishes the depth of the box by \footsep to shift it down. It also turns off the footer (with an \AtBeginShipout), and sets up a reactivation of the footer for the next page (by doing a nested \AtBeginShipout).

\documentclass{book}

\usepackage{lipsum,atbegshi}
\usepackage{multicol}
\usepackage{color}

\usepackage{geometry}
\geometry{a5paper,textwidth=132mm,textheight=190mm}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\thepage}

\newcommand{\replaceFooterFig}[1]{% all necessary code goes here
\begin{figure*}[b!]
\fboxsep=0pt\setbox0=\vbox{%
\begin{minipage}[t]{\textwidth}\color{red}#1\end{minipage}%
}\dp0=\dimexpr\dp0-\footskip\relax\box0
\AtBeginShipout{\fancyhf{}\nextpagefoot}
\end{figure*}
}
\def\nextpagefoot{\AtBeginShipout{\fancyfoot[C]{\thepage}}}
\begin{document}

\begin{multicols}{2}

\lipsum[1-10]

\replaceFooterFig{
I should replace the footer (no gap to page border, multicols above makes use of the additional space!).
\lipsum[1]
}

\lipsum[11-20]

\replaceFooterFig{
I am shorter, but I should replace the footer, too.
\lipsum[2]
}

\lipsum[21-30]

\end{multicols}

\end{document}


• This too works great, but two figures on the same page overlap slightly. Is that easy to fix (though not really necessary for my usecase)? – TeXter May 11 '16 at 4:47
• @TeXter There is no simple way to automatically undo this shift, if two images end up on the same page, which is, I gather your hope. – Steven B. Segletes May 11 '16 at 10:46
• Ah, ok. I can live with that. – TeXter May 12 '16 at 4:56

Moving the figure in the footer is not really difficult. This can be done with a simple vspace. But is is not so easy to suppress the printing of the page number in the footer. The following code works but relies on the fact that \thepage doesn't do silly thinks ...

\documentclass{book}

\usepackage{lipsum}
\usepackage{multicol}
\usepackage{color}
\usepackage{etoolbox}
\usepackage{geometry}
\geometry{a5paper,textwidth=132mm,textheight=190mm}
\newcommand\myfloatlist{}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\edef\temp{\thepage}\expandafter\ifinlist\expandafter{\temp}{\myfloatlist}{}{\thepage}}
\makeatletter
\newcommand{\replaceFooterFig}[1]{% all necessary code goes here
\begin{figure*}[b!]
\protected@write\@auxout{}%
\color{red}#1
\par\vspace{-0.8cm}
\end{figure*}}

\begin{document}

\begin{multicols}{2}

\lipsum[1-10]

\replaceFooterFig{
I should replace the footer (no gap to page border, multicols above makes use of the additional space!).
\lipsum[1]
}

\lipsum[11-20]

\replaceFooterFig{
I am shorter, but I should replace the footer, too.
\lipsum[2]
}

\lipsum[21-30]

\end{multicols}

\end{document}


• Nice, I'll try if this works with my more complex real world document. btw: if two figures happen to be on the same page, this solution does not work and they overlap, (but that that can not happen in my document/case). However, this being a bounty mission, I'll wait if someone might come up with that cherry on top. – TeXter May 9 '16 at 18:44