3

Taking the code from this excellent answer, how can I modify it to get rounded corners on all the frames?. I managed to round the main frame, but the other two are still straight:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --

\tcbset{
    titlecommon/.style={
        fontupper=\Large\bfseries\sffamily,
        top=2mm,
        bottom=2mm,
        halign=center,
        sharp corners,
        leftrule=0.5mm, %to draw left side in subtitle box
        rightrule=0.5mm, %to draw right side in subtitle box
        opacityfill=.5,  %to test subtitles geometry and positioning
    },
    toptitle/.style={
        titlecommon,
        colframe=green,
        colback=green!20,
    },
    bottomtitle/.style={
        titlecommon,
        colframe=red,
        colback=red!20,
    },
}   

\newtcolorbox{twotitle}[3][]{
    enhanced,
    arc=5pt,
    % sharp corners,
    colback=white,
    colframe=black!75,
    notitle,
    before upper={\tcbsubtitle[toptitle]{#2}},
    after upper={\tcbsubtitle[bottomtitle]{#3}},
    top=-1.5mm, %-boxsep-toprule
    bottom=-1.5mm, %-boxsep-bottomrule
    #1,
}

\begin{document}
\begin{twotitle}[colback=orange!20]{Title}{Test}
\lipsum[1]
\end{twotitle}
\end{document}

  • Your link is not working, please edit your question. – BambOo Sep 22 at 11:46
  • It should work now. – noibe Sep 22 at 12:00
  • @DavidPurton this would actually be relevant only for the first part of the box – BambOo Sep 22 at 12:11
  • 1
    @BambOo, yes I didn't read close enough. Just about to post an answer similar to yours. – David Purton Sep 22 at 12:13
5

After a bit of tweaking

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --

\tcbset{
    titlecommon/.style={
        fontupper=\Large\bfseries\sffamily,
        top=2mm,
        bottom=2mm,
        halign=center,
        sharp corners,
        leftrule=0.5mm, %to draw left side in subtitle box
        rightrule=0.5mm, %to draw right side in subtitle box
        opacityfill=1,  %to test subtitles geometry and positioning
        arc=5pt,
    },
    toptitle/.style={
        titlecommon,
        colframe=green,
        colback=green!20,
        rounded corners=north,
    },
    bottomtitle/.style={
        titlecommon,
        colframe=red,
        colback=red!20,
        rounded corners=south,
    },
}   

\newtcolorbox{twotitle}[3][]{
    arc=5pt,
    enhanced,
    % sharp corners,
    colback=white,
    colframe=black!75,
    notitle,
    before upper={\tcbsubtitle[toptitle]{#2}},
    after upper={\tcbsubtitle[bottomtitle]{#3}},
    top=-1.5mm, %-boxsep-toprule
    bottom=-1.5mm, %-boxsep-bottomrule
    #1,
}

\begin{document}
\begin{twotitle}[colback=orange!20]{Title}{Test}
\lipsum[1]
\end{twotitle}
\end{document}

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.