6

I have made a box using tcolorbox That looks like this: enter image description here

However, I would like the "title box" to have rounded corners (same diameter as the larger box) only in the top left corner and bottom right corner. The top right and bottom left I would like to keep sharp (as is). How do I do this?

enter image description here

Here is a MWE:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{tikz, adjustbox}
\usepackage{xcolor}

\definecolor{background_color}{rgb}{0.95,0.95,0.95}
\definecolor{icons}{HTML}{46A247}

\newtcolorbox{emph_box}[1][]{%
    enhanced,
    before skip=2mm,after skip=2mm, 
    boxrule=0.6pt,
    colback=background_color, colframe=icons, % Colors
    attach boxed title to top left={xshift=0cm,yshift*=0mm-\tcboxedtitleheight},
    varwidth boxed title*=-3cm,
    % The titlebox:
    boxed title style={frame code={%
        \path[left color=icons,right color=icons,
        middle color=icons]
        ([xshift=-0mm]frame.north west) -- ([xshift=0mm]frame.north east)
        [rounded corners=0mm]-- ([xshift=0mm,yshift=0mm]frame.north east)
        -- (frame.south east) -- (frame.south west)
        -- ([xshift=0mm,yshift=0mm]frame.north west)
        [sharp corners]-- cycle;
        },interior engine=empty,
    },
    width=\textwidth,
    arc is curved,
    arc = 1.5mm,
    fonttitle=\bfseries, 
    title={#1}
}

\begin{document}

\begin{emph_box}[Title]
    Some text
\end{emph_box}

\end{document}

2 Answers 2

7

You can decide on a corner-by-corner basis if it should be rounded or sharp like this:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{tikz, adjustbox}
\usepackage{xcolor}

\definecolor{background_color}{rgb}{0.95,0.95,0.95}
\definecolor{icons}{HTML}{46A247}

\newtcolorbox{emph_box}[1][]{%
    enhanced,
    before skip=2mm,after skip=2mm, 
    boxrule=0.6pt,
    colback=background_color, colframe=icons, % Colors
    attach boxed title to top left={xshift=0cm,yshift*=0mm-\tcboxedtitleheight},
    varwidth boxed title*=-3cm,
    % The titlebox:
    boxed title style={frame code={%
        \path[left color=icons,right color=icons, middle color=icons]
        (frame.north west) [sharp corners] -- 
        (frame.north east) [rounded corners=2mm] -- 
        (frame.south east) [sharp corners] -- 
        (frame.south west) [rounded corners=2mm] -- 
        cycle;
        },interior engine=empty,
    },
    width=\textwidth,
    arc is curved,
    arc = 1.5mm,
    fonttitle=\bfseries, 
    title={#1}
}

\begin{document}

\begin{emph_box}[Title]
    Some text
\end{emph_box}

\end{document}

enter image description here

8

The title box can be a tcolorbox so you can apply similar options:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{tikz, adjustbox}
\usepackage{xcolor}

\definecolor{background_color}{rgb}{0.95,0.95,0.95}
\definecolor{icons}{HTML}{46A247}

\newtcolorbox{emph_box}[1][]{%
    enhanced,
    before skip=2mm,after skip=2mm, 
    boxrule=0.6pt,
    colback=background_color, colframe=icons, % Colors
    attach boxed title to top left={xshift=0cm,yshift*=0mm-\tcboxedtitleheight},
    varwidth boxed title*=-3cm,
    % The titlebox:
%    boxed title style={frame code={%
%        \path[left color=icons,right color=icons,
%        middle color=icons]
%        ([xshift=-0mm]frame.north west) -- ([xshift=0mm]frame.north east)
%        [rounded corners=0mm]-- ([xshift=0mm,yshift=0mm]frame.north east)
%        -- (frame.south east) -- (frame.south west)
%        -- ([xshift=0mm,yshift=0mm]frame.north west)
%        [sharp corners]-- cycle;
%        },interior engine=empty,
%    },
     boxed title style={sharp corners=uphill, colback=icons},
    width=\textwidth,
    arc is curved,
    arc = 1.5mm,
    fonttitle=\bfseries, 
    title={#1}
}

\begin{document}

\begin{emph_box}[Title]
    Some text
\end{emph_box}

\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 .