I sometimes use a figure which extends into the marginpar and towards the page header while being placed at the top, something like that
generated from this MWE:
\documentclass[automark]{scrbook}
\usepackage{graphicx}
\begin{document}
\chapter{My Chapter}
\clearpage
\section{My Section Left}
pewpew
% So that we have a headmark on the right
\clearpage
\section{My Section Right}
Here is some text. Followed by a float extending into the marginpar and to
the top.
\begin{figure}[t]
\begin{addmargin*}[0pt]{\dimexpr-\marginparwidth - \marginparsep}
\vspace*{-\headsep}
\begin{minipage}{\linewidth}
\rule{\textwidth}{5cm}
\caption{Foo}
\end{minipage}
\end{addmargin*}
\end{figure}
Compare this to a normal inline figure.
\begin{figure}[htbp]
\rule{\textwidth}{5cm}
\caption{Bar}
\end{figure}
\end{document}
For the final page where the float is being placed, I want to remove the page header, ie, \thispagestyle{empty}.
However, for the life of mine, I'm unable to achieve this. I have found no way to reliably run \thispagestyle{} on the actual page. I tried the floatpag package, everypage package, etc. but nothing worked. Sometimes, the style is applied to the page before or after.
I'm using the scrbook class.
Edit:
The only reliable way I've found to be working, is a simple hack to place a white \rule on top of the text, \ie, move the figure a bit more to the top and put the \rule in this place. That however only works for the top (sufficient for me though) and the text can still be selected in the resulting PDF (it is still there).
\vspace*{\dimexpr-\headsep - 1cm}\textcolor{white}{\rule{\linewidth}{1cm}\\[0pt]}
Edit 2: I found this answer to basically the same question. However, this only works if you define the label list that is being created upfront, not dynamically. If the list is build dynamically by using \listxadd in place of the figure, the shipout hook does not see the added label if the figure is not moved to the next page, which means it misses some pages where to change the page style. Note that I would prefer this dynamic way, as I use a key-value-command to build these figures and do want to do everything automatically in there.
[p]floats, which does not apply here. But thanks. – laser3000 Mar 30 '20 at 16:14