I am trying to wrap a tikz figure inside a breakable tcolorbox but I fail doing so because of the pagebreaks. I tried wrapping it using minipage, but this is obviously a bad idea because minipage doesn't handle pagebreak - as the name implies. But I encountered the same issue with wrapfigure : the text will not cause any issue but the figure might well get out of the tcolorbox before a pagebreak. Below is a MWE - the M is probably not very correct in MWE but I figured out I would use the exact same code that runs the issue for me.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[OT1]{fontenc}
\usepackage[french]{babel}
\usepackage{wrapfig}
\usepackage[breakable,skins]{tcolorbox}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usepackage{amsmath}
\newcommand{\ang}[1]{\widehat{#1}}
\begin{document}
\begin{tcolorbox}[boxrule=0.5pt,breakable,enhanced,colframe=black,parbox=false]%
\textbf{\MakeUppercase{Démonstration}}
\begin{wrapfigure}{r}{0.4\textwidth}
\begin{center}
\begin{tikzpicture}
\tkzDefPoint(2,1){A'}
\tkzDefPoint(-2,1.3){B'}
\tkzDefPoint(0.1,-1){C'}
\tkzDefPoint(0,0){O}
\tkzInterLC(O,A')(O,A') \tkzGetSecondPoint{A}
\tkzInterLC(O,B')(O,A') \tkzGetSecondPoint{B}
\tkzInterLC(O,C')(O,A') \tkzGetSecondPoint{C}
\tkzDefPointBy[symmetry=center O](C) \tkzGetPoint{C'}
\tkzDrawCircle(O,A')
\tkzDrawSegments[line width=0.3pt](O,A A,B B,O B,C C,A O,C)
\tkzDrawSegments[line width=0.6pt, dotted](O,C')
\tkzDrawPoints(A,B,C,O,C')
\tkzLabelPoints(C,O,C')
\tkzLabelPoints[above left](B)
\tkzLabelPoints[above right](A)
\tkzMarkAngle[size=0.5,mark=none](O,A,C)
\tkzMarkAngle[size=0.5,mark=none](A,C,O)
\tkzMarkAngle[size=0.7,mark=none](C,B,O)
\tkzMarkAngle[size=0.7,mark=none](O,C,B)
\tkzMarkAngle[size=0.73,mark=none](C,B,O)
\tkzMarkAngle[size=0.73,mark=none](O,C,B)
\end{tikzpicture}
\end{center}
\end{wrapfigure}
Nous traitons d'abord le cas où le centre du cercle $O$ est contenu dans le triangle $ABC$.
On commence par remarquer que le triangle $OAC$ est isocèle en $O$ ainsi
\begin{align*}
\ang{OAC} = \ang{ACO}
\end{align*} Puisque la somme des angles d'un triangle vaut $180^{\circ}$, nous avons
\begin{align*}
\ang{COA} = 180^{\circ} - 2 \cdot \ang{ACO}
\end{align*} Le triangle $OBC$ est également isocèle en $O$, ainsi
\begin{align*}
\ang{OCB} = \ang{CBO}
\end{align*} et par le même raisonnement qu'avant
\begin{align*}
\ang{BOC} = 180^{\circ} - 2 \cdot \ang{OCB}
\end{align*}
Soit $C'$ le point du cercle diamétralement opposé à $C$. Alors les angles $\ang{COA}$ et $\ang{AOC'}$ sont supplémentaires. On a alors
\begin{align*}
\ang{AOC'} &= 180 -\ang{AOC} \\
&= 180 -\left(180-2\cdot\ang{ACO}\right) \\
&= 2\cdot\ang{ACO}
\end{align*}
Par le même raisonnement, nous trouvons $\ang{C'OB} = 2\cdot \ang{OCB}$. Nous obtenons:
\begin{align*}
\ang{AOB} &= \ang{AOC'} + \ang{C'OB} \\
&= 2\cdot\ang{ACO} + 2\cdot\ang{OCB} \\
&= 2\cdot\left(\ang{ACO} + \ang{OCB}\right) \\
&= 2\cdot\ang{ACB}
\end{align*}
\begin{wrapfigure}{r}{0.4\textwidth}
\begin{center}
\begin{tikzpicture}
\tkzDefPoint(2,1){A'}
\tkzDefPoint(0.1,1.3){B'}
\tkzDefPoint(1,-1){C'}
\tkzDefPoint(0,0){O}
\tkzInterLC(O,A')(O,A') \tkzGetSecondPoint{A}
\tkzInterLC(O,B')(O,A') \tkzGetSecondPoint{B}
\tkzInterLC(O,C')(O,A') \tkzGetSecondPoint{C}
\tkzDefPointBy[symmetry=center O](C) \tkzGetPoint{C'}
\tkzDrawCircle(O,A')
\tkzDrawSegments[line width=0.3pt](O,A A,B B,O B,C C,A O,C)
\tkzDrawSegments[line width=0.6pt, dotted](O,C')
\tkzDrawPoints(A,B,C,O,C')
\tkzLabelPoints(C)
\tkzLabelPoints[below left](O)
\tkzLabelPoints[above right](A,B)
\tkzLabelPoints[above left](C')
\tkzMarkAngle[size=0.5,mark=none](O,A,C)
\tkzMarkAngle[size=0.5,mark=none](A,C,O)
\tkzMarkAngle[size=0.7,mark=none](O,B,C)
\tkzMarkAngle[size=0.7,mark=none](B,C,O)
\tkzMarkAngle[size=0.73,mark=none](O,B,C)
\tkzMarkAngle[size=0.73,mark=none](B,C,O)
\end{tikzpicture}
\end{center}
\end{wrapfigure}
Il nous reste à traiter le cas où $O$ est à l'extérieur du triangle $ABC$. Sans nuire à la généralité, on suppose que les points sont dans l'ordre $ABC$ (sens anti-horaire) - le cas $ACB$ étant similaire. On pose à nouveau $C'$ le point du cercle diamétralement opposé à $C$. Par le cas précèdent nous obtenons
\begin{align*}
\ang{AOC'} = 2 \cdot \ang{ACC'}
\end{align*} et
\begin{align*}
\ang{BOC'} = 2 \cdot \ang{BCC'}
\end{align*} Finalement :
\begin{align*}
\ang{AOB} &= \ang{AOC'} - \ang{BOC'} \\
&= 2\cdot \ang{ACC'} - 2 \cdot \ang{BCC'} \\
&= 2 \cdot \left(\ang{ACC'} - \ang{BCC'}\right) \\
&= 2 \cdot \ang{ACB}
\end{align*}
\end{tcolorbox}
\end{document}
As you can see, the second goes well out of the box and even the page in this code.
Is there a way to combine wrapfigure and a breakable tcolorbox or those 2 are just incompatible ? And if they are, what combination could I use with tcolorbox - I might use something else than wrapfigure but I don't wnat to give up on tcolorbox.
Thanks in advance for the enlightment.
wrapfigurebeing placed too closed to a pagebreak. So it is not an incompatibility issue, but you would have the same problem outside of atcolorboxas well. See https://tex.stackexchange.com/q/56176/47927 . You could perhaps place a\clearpagebefore the secondwrapfigure. – Jasper Habicht Jul 28 '22 at 12:48\pagebreakas possible. Any other package than wrapfigure might do the same without this issue ? If none, then I'll manually add commands every time this issue arises. – HerculePoivrot Jul 28 '22 at 13:52