2

I have experienced some strange breaking in tcolorbox when I ran the MWE below:

\documentclass[openany]{book}
\usepackage[many]{tcolorbox}
\definecolor{boxblue}{RGB}{128,128,128}
\newtcolorbox[auto counter,number within=chapter]{myact}{
 enhanced,
    breakable,
    colback=white,
    colframe=boxblue,
    arc=3mm,
          sharp corners,
      rounded corners=southeast,
    boxrule=0.5pt,
    fontupper=,
    before upper={\parindent0pt\vspace{8pt}},
    top=4mm, bottom=2mm, left=4mm, right=4mm,
    overlay={
      % === Triple Circle Pen Icon ===
      \node[fill=white, draw=boxblue, circle, minimum size=21.7pt, inner sep=0pt] 
        at ([xshift=2.5pt,yshift=-.1pt]title.west) {};
      \node[fill=boxblue, draw=boxblue, circle, minimum size=17pt, inner sep=0pt]
        at ([xshift=2.5pt,yshift=-.3pt]title.west) {};
      \node[fill=white, draw=white, text=boxblue, font=\small, circle, minimum size=14pt, inner sep=0pt]
        at ([xshift=2.5pt,yshift=-.3pt]title.west) {\includegraphics[clip,width=.5cm,height=.5cm,keepaspectratio]{act2}};
    },
    title={\hspace{.1cm}\textbf{Activity} \thetcbcounter},
    coltitle=white,
    attach boxed title to top left={
      xshift=-1.3mm,
      yshift=-7.6mm % Move title down to align with frame
    },
    boxed title style={
      colback=boxblue,
      boxrule=0pt,
      top=2pt, bottom=2pt, left=8pt, right=8pt,
      sharp corners,
      rounded corners=southeast,
      arc=3mm
    }
}
\begin{document}
\chapter{My Cha}
\vspace{10cm}
\begin{myact}
The sub-shells are split further into orbitals [region of space around the nucleus
where the probability of finding a particular electron is maximum] where the
electrons are placed.\\[2ex]
Each atomic orbital can carry a maximum of two electrons.\\
The s sub-shell has one orbital, p sub-shell has three orbitals, d sub-shell has
five orbitals and f sub-shell has seven orbitals.\\[2ex]
Hence s, p, d and f sub-shells [when fully filled] can carry a maximum of 2, 6,
10 and 14 electrons respectively.
\end{myact}
\end{document}

Output seen below:

enter image description here

Any workaround to relief me from my headache.

Thanks in advance

2
  • (You shouldn't abuse \\ for line breaks!) Commented yesterday
  • @samcarter_is_at_topanswers.xyz and the community accept my apology for misusing and abusing \\
    – Uncle C
    Commented 23 hours ago

1 Answer 1

6

Use overlay unbroken and first instead of overlay to add your icon only to the first box:

\documentclass[openany]{book}
\usepackage[many]{tcolorbox}
\usepackage{parskip}
\definecolor{boxblue}{RGB}{128,128,128}
\newtcolorbox[auto counter,number within=chapter]{myact}{
    parbox=false,
    enhanced,
    breakable,
    colback=white,
    colframe=boxblue,
    arc=3mm,
          sharp corners,
      rounded corners=southeast,
    boxrule=0.5pt,
    fontupper=,
    before upper={\parindent0pt\vspace{8pt}},
    top=4mm, bottom=2mm, left=4mm, right=4mm,
    overlay unbroken and first={
      % === Triple Circle Pen Icon ===
      \node[fill=white, draw=boxblue, circle, minimum size=21.7pt, inner sep=0pt] 
        at ([xshift=2.5pt,yshift=-.1pt]title.west) {};
      \node[fill=boxblue, draw=boxblue, circle, minimum size=17pt, inner sep=0pt]
        at ([xshift=2.5pt,yshift=-.3pt]title.west) {};
      \node[fill=white, draw=white, text=boxblue, font=\small, circle, minimum size=14pt, inner sep=0pt]
        at ([xshift=2.5pt,yshift=-.3pt]title.west) {\includegraphics[clip,width=.5cm,height=.5cm,keepaspectratio]{example-image-duck}};
    },
    title={\hspace{.1cm}\textbf{Activity} \thetcbcounter},
    coltitle=white,
    attach boxed title to top left={
      xshift=-1.3mm,
      yshift=-7.6mm % Move title down to align with frame
    },
    boxed title style={
      colback=boxblue,
      boxrule=0pt,
      top=2pt, bottom=2pt, left=8pt, right=8pt,
      sharp corners,
      rounded corners=southeast,
      arc=3mm
    }
}
\begin{document}
\chapter{My Cha}
\vspace{10cm}
\begin{myact}
The sub-shells are split further into orbitals [region of space around the nucleus
where the probability of finding a particular electron is maximum] where the
electrons are placed.

Each atomic orbital can carry a maximum of two electrons.

The s sub-shell has one orbital, p sub-shell has three orbitals, d sub-shell has
five orbitals and f sub-shell has seven orbitals.

Hence s, p, d and f sub-shells [when fully filled] can carry a maximum of 2, 6,
10 and 14 electrons respectively.
\end{myact}
\end{document}

enter image description here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.