I want to create an environment for visually marking sections of text as "needs to be redone", "unfinished" or similar. For that purpose I want to put a colored frame around the sections, which I normally would do with tcolorbox
.
However, these content parts routinely include floats (figures, tables). Floats inside tcolorbox (and supposedly likewise for mdframed) don't work.
Is there some way to achieve visual markup across pages, that allows having floats?
Example code
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage[scale=0.95,a6paper]{geometry}
\usepackage[skins,breakable]{tcolorbox}
\usepackage{todonotes}
\usepackage{lipsum}
\makeatletter
\newcommand\changecolor[1]{%
\color{#1}\let\default@color\current@color
}
\makeatother
\begin{document}
THIS WORKS WELL, BUT LACKS SOME ASPECTS \\
SUCH AS HIGHLIGHTING ACCIDENTIALLY \\
NESTED ENVRIONMENTS. \\
\newenvironment{needsreview_simple}[1][]{
\par\noindent\changecolor{blue}%
\hrulefill\space
\textsc{#1}%
\space\hrulefill\par
}{
\par\noindent\hrulefill\par
}
\begin{needsreview_simple}[Some stuff]
\lipsum[1-2]
\begin{figure}
\centering
\missingfigure{hello world}
\caption{Hello world}
\end{figure}
\begin{needsreview_simple}[Nested]
\lipsum[3]
\end{needsreview_simple}
\end{needsreview_simple}
\clearpage
THIS VARIANT CREATES ERRORS BECAUSE \\
THE FIGURE ENVIRONMENT ISN'T ALLOWED \\
INSIDE A TCOLORBOX. THE FLOAT IS \\
**LOST** AS A CONSEQUENCE. \\
\newenvironment{needsreview_tcbox}[1][]{%
\tcolorbox[enhanced,breakable,colframe=blue,col=blue,title={\textsc{#1}}]%
\changecolor{blue}%
}{
\endtcolorbox
}
\begin{needsreview_tcbox}[Some stuff]
\lipsum[1-3]
\begin{figure}
\centering
\missingfigure{hello world}
\caption{Hello world}
\end{figure}
\end{needsreview_tcbox}
\end{document}