How do I make a bottom float replace the footer?
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{}%
{\string\listgadd{\string\myfloatlist}{\thepage}}%
\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}
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}