Como usar um ambiente marginfigure dentro de um ambiente tcolorbox?

Como usar um ambiente marginfigure dentro de um ambiente tcolorbox?
\documentclass{book}
\usepackage[demo]{graphicx}
\usepackage[paperwidth=170mm, paperheight=240mm, left=42pt, top=40pt, textwidth=280pt, marginparsep=20pt, marginparwidth=100pt, textheight=560pt, footskip=40pt]{geometry}
\usepackage{lipsum}
\usepackage{sidenotes}
\usepackage[many]{tcolorbox}
\begin{document}
A test
\begin{tcolorbox}
\lipsum[1]
\begin{marginfigure}%[!h]
\includegraphics[width=\linewidth]{fig1}
\caption{A test caption}
\label{fig1}
\end{marginfigure}
\end{tcolorbox}

\end{document}

Quando executo o código acima, recebo alguns erros:

! LaTeX Error: Not in outer par mode.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.15 \end{marginfigure}
? r
OK, entering \nonstopmode...
! Undefined control sequence.
<argument> \@marbox
l.15 \end{marginfigure}

Como posso resolver este problema?

Responder1

Por outro lado, caixa na figura de margem:

\documentclass{book}
\usepackage[demo]{graphicx}
\usepackage[paperwidth=170mm, paperheight=240mm, left=42pt, top=40pt, textwidth=280pt, marginparsep=20pt, marginparwidth=100pt, textheight=560pt, footskip=40pt]{geometry}
\usepackage{lipsum}
\usepackage{sidenotes}
\usepackage[many]{tcolorbox}
\begin{document}
A test

\lipsum[1]
\begin{marginfigure}%[!h]
\begin{tcolorbox}
\includegraphics[width=\linewidth]{fig1}
\caption{A test caption}
\label{fig1}
\end{tcolorbox}
\end{marginfigure}


\end{document}

informação relacionada