1

I have a tcolorbox inside another tcolorbox (I think), and I set both breakable. However, when the texts inside the inner box are more than one page, they refuse to go to the second page. Basically I want the texts to go the next page... naturally, while still inside the box.

\documentclass\[12pt\]{amsart}
\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots.
\geometry{a4paper} % or letter or a5paper or ... etc

\usepackage{xcolor, colortbl}
\usepackage{marginnote}
\usepackage{tikz}

%%% begin You Try It!%%%%%%%%
\usepackage\[many\]{tcolorbox}
\usetikzlibrary{calc}
%%%%% example
\tcbset{exa/.style={  breakable,  enhanced, %  outer arc=0pt,
  arc=4pt,  boxrule=0.0pt,  colframe=brown!50!blue,  colback=brown!5!white,
  attach boxed title to top left,  boxed title style={    colback=brown!50!blue,
%    outer arc=0pt,
    arc=4pt,    top=-1pt,    bottom=-1pt,
    },  fonttitle=\sffamily
  }
}
%%
\newtcolorbox\[auto counter\]{sgex}\[1\]\[\]{
  exa,
  title=Example ~\thetcbcounter,
  overlay unbroken and first={
      \path
        let
        \p1=(title.north east),
        \p2=(frame.north east)
        in
        node\[anchor=west,font=\sffamily,color=brown!50!blue,text width=\x2-\x1\] 
        at (title.east) {#1};
  }
}
%%%%%
\definecolor{framerule}{RGB}{183,41,41}
\colorlet{tryit}{green!70!black}
\newcommand\RedBox{\textcolor{framerule}{$\square$}}

\newtcolorbox{eoexample}{
  enhanced,
  breakable,
  toggle left and right,
  boxrule=0pt,
  colback=white,
  arc=0pt,
  outer arc=0pt,
  top=\topsep,
  bottom=\topsep,
  left=0pt,
  right=0pt,
  boxsep=3pt,
  overlay unbroken ={%
      \node\[draw,tryit,fill=white\]
      (tryit)
      at (\[xshift=\marginparsep+0.5\marginparwidth\]frame.north east)
      {You Try It!};
      \draw\[framerule\]
        (frame.north west) -- (\[xshift=-3pt\]tryit.west);
      \draw\[framerule\]
        (\[xshift=3pt\]tryit.east) --
        (\[xshift=\marginparsep+\marginparwidth\]frame.north east);
      \node\[inner sep=0pt, anchor=east\]
        (box)
        at (\[xshift=\marginparsep+\marginparwidth\]frame.south east)
        {\RedBox};
      \draw\[framerule\]
        (frame.south west) --
        (\[xshift=-3pt\]box.west);
},
 overlay first={%
      \node\[draw,tryit,fill=white\]
      (tryit)
      at (\[xshift=\marginparsep+0.5\marginparwidth\]frame.north east)
      {You Try It!};
      \draw\[framerule\]
        (frame.north west) -- (\[xshift=-3pt\]tryit.west);
      \draw\[framerule\]
        (\[xshift=3pt\]tryit.east) --
        (\[xshift=\marginparsep+\marginparwidth\]frame.north east);        
 },
} 

\newtheoremstyle{myexa}% name
  {\topsep}%Space above
  {\topsep}%Space below
  {}%Body font
  {}%Indent amount 1
  {\bfseries}% Theorem head font
  {.}%Punctuation after theorem head
  {.5em}%Space after theorem head 2
  {}%Theorem head spec

\theoremstyle{myexa}
\newtheorem{exa}{EXAMPLE}
    \usepackage{xparse}
\NewDocumentEnvironment{example}{ooO{12}}
      {\begin{eoexample}
      \begin{sgex}%
        \IfNoValueF{#1}{\marginnote{\flushleft{\color{framerule}{#1}}}\[-10mm\]}}%
      {\IfNoValueF{#2}{\marginnote{\flushleft{\color{framerule}{#2}}}\[-#3mm\]}%
       \end{sgex}\end{eoexample}}
\allowdisplaybreaks
%%%end  You Try It!%%%%%%%%%%%%

\usepackage{lipsum}

\begin{document}

\begin{example}\[question\]\[answer\]
\lipsum\[1-6\]
\end{example}

\end{document}

enter image description here

  • Somehow, your code/edits/etc. has turned [...] into \[...\], which is probably not what you meant.... – jon May 24 '16 at 4:08
  • 6
    Inner boxes are not breakable. Page 350 in tcolorbox documentation. – Ignasi May 24 '16 at 6:58
  • 3
    @SeanN: Well, inner boxes are breakable, but the result is a mess (in 99.9% of all cases) You must find another strategy – user31729 May 24 '16 at 8:14
  • 2
    Possible duplicate of: tex.stackexchange.com/questions/310100/… – user31729 May 24 '16 at 10:18

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.