3

I have the following code:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usetikzlibrary{calc}

\definecolor{myblue}{RGB}{0,163,243}

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

\newtcolorbox[auto counter]{assumption}[1][]{
  mystyle,
  colback=white,
  rightrule=0pt,
  toprule=0pt,
  title=Assumption SLR.\thetcbcounter,
  overlay unbroken and first={
      \path
        let
        \p1=(title.north east),
        \p2=(frame.north east)
        in
        node[anchor=west,font=\sffamily,color=myblue,text width=\x2-\x1] 
        at (title.east) {#1};
  }
}

\begin{document}

\begin{assumption}
test
\end{assumption}

\end{document}

Which results with this: enter image description here

What I would like to have is this: enter image description here

Can anyone help me?

1 Answer 1

4

There are two important attach options here:

attach boxed title to top left={yshift=-\tcboxedtitleheight, yshifttext=-\baselineskip}

i.e. shifting the box downwards by the height of the box (\tcboxedtitleheight) and give additional spacings for the main box such that the boxed title does not overlap the main text area with yshifttext=-\baselineskip, where \baselineskip is just an example.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}

\definecolor{myblue}{RGB}{0,163,243}

\tcbset{mystyle/.style={
  breakable,
  enhanced,
  sharp corners,
  colframe=myblue,
  colback=myblue!20,
  attach boxed title to top left={yshift=-\tcboxedtitleheight, yshifttext=-\baselineskip},
  boxed title style={
    enhanced,
    sharp corners,
    colback=myblue,
    top=2pt,
    bottom=2pt,
    size=small,
    },
  fonttitle=\sffamily
  },
}

\newtcolorbox[auto counter]{assumption}[1][]{
  mystyle,
  colback=white,
  title=Assumption SLR.\thetcbcounter,
}

\begin{document}

\begin{assumption}
test
\end{assumption}

\end{document}

enter image description here

You must log in to answer this question.

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