I am using the tufte-book
class to write my notes and I would like to have tcolorbox
theorems that can contain marginfigures and sidenotes (provided by the sidenotes
package). Following I will post a MWE and the error I have in both situations:
\documentclass[nobib,notoc, a4paper]{tufte-book}
% For the example image
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel} % Italian support
\usepackage[utf8]{inputenc} % Accented letters
\usepackage[theorems]{tcolorbox}
\newtcbtheorem{Thm}{Teorema}%
{colback=green!5,colframe=green!35!black,fonttitle=\bfseries}{thm}
\begin{document}
\mainmatter
\begin{Thm}{Titolo}{esempio}
Esempio di teorema.
%\sidenote{Una nota a margine}
\begin{marginfigure}
\includegraphics{example-image-a}
\caption{Figura di esempio}
\label{fig:ex_a}
\end{marginfigure}
\end{Thm}
\end{document}
When using the marginfigure
environment I incur in
LaTeX Error: Not in outer par mode.
while when using a side note
l.29 LaTeX Error: Float(s) lost.
l.21 Missing number, treated as zero.
I had this problem not only with tcolorbox
but also with ntheorem
(that I am currently using but moving from because I would like different styles for theorems, definitions, examples etc.)
I am basically forced to use marginfigures only outside of these environments making the positioning very tricky and the code quite messy.
I looked at this answer and this too but none of them actually solved my problem since I cannot put theorems inside marginfigures. From what I understand the problem is that both marginfigures and sidenotes are floats and so are tcolorbox
' theorems and I can't create one from the other. I'm not grokking LaTeX internals well enough to develop a solution or to understand better.
Any insight for this would be greatly appreciated!
sidebyside
tcolorbox with the theorem and corresponding figure/note. But if you just want to associate them to a theorem but left them float you can declare outside theorem environment. Please, explain it better.ntheorem
environment and two rules to create the two green lines. Themarginfigure
environrment is put inside thentheorem
one, like so. (Note that\incfig
only loads both an svg and the pdf_tex file generated by Inkscape, it's not relevant). What this method achieves is that the marginfigure is automatically aligned with the theorem. If I instead ofntheorem
try to use any kind of floats (even framed theorems ortcolorbox
es), the above error shows up.tcolorbox
theorems, while also keeping the tufte style of the page.