这个问题:
几乎回答了我的问题,但还不够。floatpag 宏 \thisfloatpagestyle 可以为特定浮动设置自定义页脚,但只有当浮动出现在仅浮动的页面上时才如此。
当特定浮动元素到达的页面不是仅浮动页面时,如何让自定义页脚出现在该页面上?
-瑞安
答案1
下面使用我评论中列出的方法。至少需要运行两次才能正确。
\documentclass[]{article}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{refcount}
\makeatletter
\newcommand*\float@foot{}
\newcommand\floatfoot@remove[1]
{%
\begingroup
\long\def\floatfoot@remove@##1#1##2\endfloatfoot@remove@
{%
\gdef\float@foot{##1##2}%
}%
\expandafter\floatfoot@remove@\float@foot\endfloatfoot@remove@
\endgroup
}
\newcommand\floatfoot[2]
{%
\expandafter\g@addto@macro\expandafter\float@foot\expandafter
{%
\csname float@foot@#1\endcsname
}%
\expandafter\gdef\csname float@foot@#1\endcsname
{%
\ifcsname r@#1\endcsname
\ifnum\getpagerefnumber{#1}=\value{page}
#2%
\expandafter\floatfoot@remove\csname float@foot@#1\endcsname
\fi
\fi
}%
}
\fancyhead[C]{\float@foot}
\makeatother
\usepackage{duckuments} % only for dummy content (also randomizes the ducks)
\usepackage{hyperref} % only to test whether it works with hyperref loaded
\pagestyle{fancy}
\begin{document}
\blindduck[1-5]
\begin{figure}% >>>
\centering
\includegraphics{example-image-duck}%
\caption
{%
a duck%
\label{fig:duck1}%
}%
\floatfoot{fig:duck1}{Page containing a duck}% might be used anywhere before
\end{figure}% <<<
\begin{figure}% >>>
\centering
\includegraphics{example-image-duck}%
\caption
{%
a duck%
\label{fig:duck2}%
}%
\floatfoot{fig:duck2}{Page containing the second duck}%
\end{figure}% <<<
\end{document}