# Box with rounder corners, but inverted

I am a long time LaTeX user, and recently I needed something which I could not figure out by myself, so I would appreciate anyones time and help.

I need a box with rounded corners, which is easy to do - for example, this thread shows how: How to draw frame with rounded corners around box

and I used the mdframed environment to do it. However, now I want to invert the rounded corners, so that the centre of the circle lies in the corner of the box. Actually, what I am trying to achieve is this:

But I don't know how to do it, so I would like to ask for your help.

The lines of code could have been reduced but here it is using tcolorbox:

\documentclass{scrbook}
\usepackage{lipsum}
\usepackage{tcolorbox}

\tcbuselibrary{skins}
\usetikzlibrary{calc}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\newtcolorbox{mybox}{
colback=red!5!white,
%width=\linewidth/2, Change the width
left=20pt, % left space between content text and box
top=20pt,
bottom=20pt,
right=20pt,
skin=freelance,
frame code={%
\begin{pgfonlayer}{foreground}
\draw[line width = 2pt,color = blue!30] ($(frame.south west) +(-4pt,-4pt)$) rectangle ($(frame.north east)+(4pt,4pt)$); %% outer rectangle
\clip (frame.south west) rectangle (frame.north east);
\draw[line width = 2pt,color=red!75!black,fill = white] (frame.south west) circle (25pt);
\draw[line width = 2pt,color=red!75!black,fill = white] (frame.north west) circle (25pt);
\draw[line width = 2pt,color=red!75!black,fill = white] (frame.north east) circle (25pt);
\draw[line width = 2pt,color=red!75!black,fill = white] (frame.south east) circle (25pt);
\draw[line width = 4pt,color=red!75!black]
($(frame.south west) +(0pt,24pt)$) -- ($(frame.north west)+(0pt,-24pt)$)  ; %% west
\draw[line width = 4pt,color=red!75!black]
($(frame.north west) +(24pt,0pt)$) -- ($(frame.north east)+(-24pt,0pt)$)  ; %% north
\draw[line width = 4pt,color=red!75!black]
($(frame.north east) +(0pt,-24pt)$) -- ($(frame.south east)+(0pt,24pt)$)  ; %% east
\draw[line width = 4pt,color=red!75!black]
($(frame.south west) +(24pt,0pt)$) -- ($(frame.south east)+(-24pt,0pt)$)  ; %% south
\end{pgfonlayer}
},
}

\begin{document}

\begin{mybox}
\lipsum[1]
\end{mybox}

\end{document}


• I was sure you had a good answer for this question ;-) – karlkoeller Sep 15 '13 at 21:49

A solution using mdframed and allowing page breaks; simply changing the value for \myRad you can get different separations and values for the radius of the arc:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}

\newmdenv[
settings={\tikzset{line cap=rect}},
singleextra={
},
middleextra={
},
firstextra={
},
secondextra={
}
]{invcor}

\begin{document}

\begin{invcor}
\lipsum[2]
\end{invcor}

\begin{invcor}
\lipsum[1-7]
\end{invcor}

\end{document}


### Update:

I introduced three mdf keys myRad, myLineWd, and myLineColor allowing you to further customize the attributes (of course, frames still admit page breaks):

\documentclass[dvipsnames]{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}

\makeatletter
\newlength\mdf@@myLineWd
\define@key{mdf}{myLineWd}{\global\setlength\mdf@@myLineWd{#1}}
\define@key{mdf}{myLineColor}{\global\def\mdf@@myLineColor{#1}}

\newmdenv[
myLineWd=5pt,
myLineColor=gray!30,
singleextra={
},
middleextra={
},
firstextra={
},
secondextra={
},
]{invcor}
\makeatother

\begin{document}

\begin{invcor}
\lipsum[4]
\end{invcor}

\begin{invcor}[
myLineColor=Dandelion,
myLineWd=3pt]
\lipsum[4]
\end{invcor}

\begin{invcor}[
innerleftmargin=20pt,
innerrightmargin=20pt,
innertopmargin=20pt,
innerbottommargin=20pt,
myLineColor=Maroon,
linecolor=MidnightBlue,
linewidth=2pt,
myLineWd=3pt]
\lipsum[4]
\end{invcor}

\end{document}


Light weight approach using package pict2e: Edit: removed spurious spaces.

Edit 2: in the second approach, it was needed to fill the inside and later draw the border, for \linethickness to play the same rôle as in the first picture.

\documentclass{article}
\usepackage{pict2e}
\usepackage{color}
\usepackage{lipsum}

\begin{document}
\setlength{\unitlength}{1cm}

\begin{picture}(10,5)
\linethickness {.1\unitlength}%
\roundcap
\color[gray]{0.7}%
\put (0,0){\arc[0,90]{1}}
\Line (0,1)(0,4)
\put (0,5){\arc[270,360]{1}}
\Line (1,5)(9,5)
\put (10,5){\arc[180,270]{1}}
\Line (10,4)(10,1)
\put (10,0){\arc[90,180]{1}}
\Line (9,0)(1,0)
\color{black}%
\put (5,2.5){\makebox(0,0){\Huge\textsc{Albert Einstein}}}
\end{picture}

\bigskip
%alternative syntax allowing filling:
\begin{picture}(10,6)
\linethickness {.1\unitlength}%
\def\x {\moveto(1,0)
\circlearc {0}{0}{1}{0}{90}
\lineto(0,5)
\circlearc {0}{6}{1}{-90}{0}
\lineto(9,6)
\circlearc {10}{6}{1}{180}{270}
\lineto(10,1)
\circlearc {10}{0}{1}{90}{180}
\lineto(1,0)}%
\color[rgb]{1,.95,0.95}%
\x
\fillpath
\color[rgb]{0.7,0,0}%
\x
\strokepath
\color{blue}%
\put (5,3){\makebox(0,0){\parbox {8cm}{\footnotesize\lipsum[1]}}}
\end{picture}

\end{document}