0

I am working in a document using the tufte-book class. I would like to have a custom tcolorbox environment able to use the full page width and also able to break in between two pages.

I am including a mwe that reuses a nice example environment from Gonzalo Medina (Create a color box?). I'd like to achieve a proper behaviour for the second case, where tufte's fullwidth environment does not correctly break the custom environment. I've also tried using mdframed instead of fullwidth (as suggested Tufte book fullwidth across pages) without success :-(

Any help would be much appreciated.

\documentclass\[a4paper,symmetric,twoside,justified\]{tufte-book}       
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{mdframed}
\usepackage\[many\]{tcolorbox}
\usepackage{xcolor}   
\definecolor{mycolor}{RGB}{0,125,98}
\usetikzlibrary{calc}

\tcbset{mystyle/.style={
  breakable,
  enhanced,
  outer arc=0pt,
  arc=0pt,
  colframe=mycolor,
  colback=mycolor!20,
  attach boxed title to top left,
  boxed title style={
    colback=blue,
    outer arc=0pt,
    arc=0pt,
    top=3pt,
    bottom=3pt,
    },
  fonttitle=\sffamily
  }
}

\newtcolorbox\[auto counter,number within=section\]{example}\[1\]\[\]{
  mystyle,
  title=Example~\thetcbcounter,
  overlay unbroken and first={
      \path
        let
        \p1=(title.north east),
        \p2=(frame.north east)
        in
        node\[anchor=west,font=\sffamily,color=mycolor,text width=\x2-\x1\] 
        at (title.east) {#1};
  }
}

\begin{document}
\mainmatter
\chapter{First chapter}

\section{A section}

% example env
\begin{example}\[Example environment\]

\begin{wrapfigure}{r}{0.5\textwidth}
\rule{4cm}{2cm}
\end{wrapfigure}

\lipsum\[1\]
\end{example}

% example using tufte's fullwidth
\begin{fullwidth}
\begin{example}\[Example environment inside tufte's fullwidth\]

\begin{wrapfigure}{r}{0.5\textwidth}
\rule{4cm}{2cm}
\end{wrapfigure}

\lipsum\[1-6\]
\end{example}
\end{fullwidth}

\end{document}

enter image description here

  • any help would be much appreciated – Sergio Jun 6 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.