# Using \marginnote in \tcolorbox in tufte-latex

The tufte-book class provides a \marginnote command for putting notes in the margin. I am using the tcolorbox package to create a sort of environment that has a border, and I would like to be able to use \marginnote inside a tcolorbox, but I get the complaint Float(s) lost. I'm guessing both tcolorbox and \marginnote use floats in their implementation, and I understand that nested floats are disallowed, but I don't see any real reason that one shouldn't be able to align margin notes with text in a non-floating tcolorbox. Here's a MWE.

\documentclass{tufte-book}
\usepackage{tcolorbox}

\newtcolorbox{exbox}{}

\begin{document}

\begin{exbox}
Test\marginnote{Note}
\end{exbox}

\end{document}


Adding in nofloat as an option to the tcolorbox doesn't seem to make any difference; it is supposed to be initially set anyhow.

Is there some way to allow one to have equivalent functionality to the \marginnote command that behaves the same inside and outside a tcolorbox?

• Have a look at tex.stackexchange.com/questions/220153/…. – TeXnician Feb 16 '17 at 14:24
• @TeXnician This one doesn't compile, your link points to an example in which the code doesn't do what the OP wants it to do. – JPi Feb 16 '17 at 14:33
• tufte-book does all sorts of low level stuff that doesn't always get along with other packages. The problem is the same if you use \marginpar but disappears when you replace the tufte-book class with book or memoir. – JPi Feb 16 '17 at 14:38
• @JPi Okay, you're right, it's a tufte-book problem. The example in the link works just fine, but not for tufte. – TeXnician Feb 16 '17 at 14:44
• The problem is, that you cannot use floating material inside a box. \marginnote from the package marginnote can be used, because it is implemented to be non-floating. tufte-book defines its own \marginnote which seems to be floating... – Thomas F. Sturm Feb 16 '17 at 16:23

You can map the \marginnote command to \marginpar, this can then be used by the \marginnote from tufte:

\RequirePackage{marginnote}
\let\marginpar\marginnote
\let\marginnote\undefined

\documentclass{tufte-book}
\usepackage{tcolorbox}

\newtcolorbox{exbox}{}

\begin{document}

\begin{exbox}
Test\marginnote{Note}
\end{exbox}

\end{document}