3

Hi I wanted to make a tcolorbox breakable, because while I was using it it seems is not andr I tried to fixed but I couldn't. Thank you for your help

\documentclass{book}

\usepackage{amsmath,amssymb}
\usepackage{nccmath}

\usepackage{tcolorbox}
\tcbuselibrary{most}
\newtcolorbox[auto counter,
              number within=chapter,
              list inside=myexercise
              ]{myexercise}[1][]{%
    enhanced,
    title={{\begin{minipage}{\linewidth}\textbf{Ejercicio}~\thetcbcounter.~\textit{#1}\end{minipage}}},
    halign title=left,
    sharp corners,
    colback=white,
    coltitle=black,
    colbacktitle=white,
    boxrule=0pt,frame hidden,
    overlay unbroken={\draw[black,double] (interior.north west)--(segmentation.west);},
    boxed title style={%
      colframe=white, 
      boxrule=0pt,
      colback=white,
      left=0pt,
      right=0pt},
    attach boxed title to top left={xshift={-5pt}},
    underlay unbroken={\draw[help lines,step=3.8mm,black!20!white](interior.south west) grid (segmentation.east);},
    lower separated=false, 
    before lower = {\tcbsubtitle[colback=white, opacityback=0, colframe=black, opacityframe=0, boxrule=1pt, height=1cm,  width=2.55cm, valign=center]{\textbf{Solution:}}}
}
\begin{document}


\begin{myexercise}[This is an example of how this box works, and this is all I got and I want to write a little bit more]{}
Just text Just text Just text Just text Just text Just textJust text Just text Just text Just text Just text Just textJust text Just text Just text Just text Just text Just textJust text Just text Just text Just text Just text Just text
\tcblower
Just text Just text Just text Just text Just text Just textJust text Just text Just text Just text Just text Just textJust text Just text Just text Just text Just text Just textJust text Just text Just text Just text Just text Just text
\end{myexercise}

\end{document}

enter image description here

1 Answer 1

5
\documentclass{book}

\usepackage{amsmath,amssymb}
\usepackage{nccmath}
\usepackage{lipsum}

\usepackage{tcolorbox}
\tcbuselibrary{most}
\newtcolorbox[auto counter,
              number within=chapter,
              list inside=myexercise
              ]{myexercise}[1][]{%
    enhanced, breakable,
    title={{\begin{minipage}{\linewidth}\textbf{Ejercicio}~\thetcbcounter.~\textit{#1}\end{minipage}}},
    halign title=left,
    sharp corners,
    colback=white,
    coltitle=black,
    colbacktitle=white,
    boxrule=0pt,frame hidden,
    underlay unbroken and first={%
         \ifnumequal{\tcbsegmentstate}{0}{
            \draw[black,double] (interior.north west)--(interior.south west);
        }{\ifnumequal{\tcbsegmentstate}{1}{
                \draw[black,double] (interior.north west)--(segmentation.west);
            \begin{tcbclipinterior}
                    \draw[help lines, step=3.8mm, black!20!white](segmentation.south west) grid (frame.south east);
            \end{tcbclipinterior}
        }{\ifnumequal{\tcbsegmentstate}{2}{
            \begin{tcbclipinterior}
                    \draw[help lines, step=3.8mm, black!20!white](interior.north west) grid (interior.south east);
            \end{tcbclipinterior}
        }}}
    },
    underlay middle and last={%
         \ifnumequal{\tcbsegmentstate}{0}{
            \draw[black,double] (interior.north west)--(interior.south west);
        }{\ifnumequal{\tcbsegmentstate}{1}{
                \draw[black,double] (interior.north west)--(segmentation.west);
            \begin{tcbclipinterior}
                    \draw[help lines, step=3.8mm, black!20!white](segmentation.south west) grid (frame.south east);
            \end{tcbclipinterior}
        }{\ifnumequal{\tcbsegmentstate}{2}{
            \begin{tcbclipinterior}
                    \draw[help lines, step=3.8mm, black!20!white](interior.north west) grid (interior.south east);
            \end{tcbclipinterior}
        }}}
    },
    boxed title style={%
      colframe=white, 
      boxrule=0pt,
      colback=white,
      left=0pt,
      right=0pt},
    attach boxed title to top left={xshift={-5pt}},
    lower separated=false, 
    before lower = {\tcbsubtitle[colback=white, opacityback=0, colframe=black, opacityframe=0, boxrule=1pt, height=1cm,  width=2.55cm, valign=center]{\textbf{Solution:}}}
}
\begin{document}


\begin{myexercise}[This is an example of how this box works, and this is all I got and I want to write a little bit more]{}
\lipsum[1-10]
\tcblower
\lipsum[1-10]
\end{myexercise}

\end{document}

enter image description here

1
  • Thank you for the awnser Commented Jan 2, 2022 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .