In order to indent my proofs, I developed a package to draw lines next to my proofs (see examples here). It works ok, but when a figure is added on top of the page, the line overlaps the picture (I'm using current page text area.north east to detect where I should stop): Here is a MWE, I want to stop the line before the red line, like tcolorbox (that is the line on the left, and that I can't use because it has other issues with nested boxes):
I asked a similar question for footnotes here, that I managed to solve by hooking into footnoterule to add a tikzmark:
\def\footnoterule{\edef\my@tmp{\noexpand\tikzmark{subproofPageNumberFootnote\the\c@abspage}}\my@tmp\oldfootnoterule}
unfortunately I have no idea how to do something similar for figures. Is there a command that is used to separate the figure from the main text that I could hook into? Note that I'd like my approach to be as generic as possible, to also take into account any sort of float.
MWE:
\documentclass[]{memoir}
\usepackage{tikz}
\RequirePackage{amsmath}
\RequirePackage{amsthm}
\usepackage{graphicx}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc,tikzmark}
%%% Tcolorbox does a pretty good job to find the position where lines should be stopped...
%%% but they can't be nested.
\RequirePackage[many]{tcolorbox}
\tcolorboxenvironment{proof}{
blanker,
before skip=\topsep,
after skip=\topsep,
borderline west={0.4pt}{0.4pt}{black},
breakable,
left=2.5mm,
grow to left by=2.5mm,
}
\usepackage{lipsum}
\begin{document}
Here is my document. Blabla \footnote{Here is my first foot note.} blabla \footnote{Here is my second foot note.}.
\begin{proof}
\lipsum[1-2]
\begin{adjustwidth}{5mm}{0mm}
\lipsum[1-3]
\tikzmark{hello}
%% Draw the line, which overlaps the picture
\tikz[remember picture,overlay] \draw (pic cs:hello) -- ({pic cs:hello}|-{current page text area.north east});
\end{adjustwidth}
\end{proof}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{Test figure}
\label{fig:bla}
\end{figure}
\lipsum[1]
\end{document}
