2

I'm trying to reproduce this box but with a title box placed on the top right and slightly rotated.

I am not satisfied with the results: the right and left border rules are not very parallel and the corners are not rounded in the same way. Can you help me please ? What I want I got this

% code

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz,tikzpagenodes}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usetikzlibrary{intersections, patterns}
\tcbuselibrary{skins}
\usepackage{lipsum}
\usepackage{xcolor,etoolbox}


\definecolor{titlecolor}{RGB}{199,232,250}

\newcommand{\titlecurve}{
  \fill[titlecolor,ultra thick]
  ($(title.south west) +(-1pt,-1pt)$) -- ($(title.north west)+(0pt,-1pt)$) coordinate(A)
  to[curve to,out=90,in=180]  ($(A)+(5pt,5pt)$)
  -- ($(title.north east)+(-5pt,0pt)$) coordinate(B)
  to[curve to,out=0,in=90] ($(B)+(6pt,-5pt)$) coordinate(C)
      --($(C)+(-0.5pt,-5pt)$) coordinate(D)
      to[curve to,out=-90,in=0] ($(D)+(-5pt,-10pt)$) coordinate(F)
      -- cycle;
    }

\newtcolorbox{oenv}{
  enhanced,
  boxrule=3pt,
  title=Temp title,%
  colframe=titlecolor,
  colback=white,
  coltitle=red,
  attach boxed title to top right={xshift=10pt, yshift=1pt},
  boxed title style={empty},
  underlay boxed title=\titlecurve

}

\begin{document}

\begin{oenv}
  Let $f$ be defined by 
\end{oenv}


\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

1 Answer 1

3

You just shift the coordinates, but I'd like to argue that rotating them around the center of the title box looks better. And rounded corners spares you from adding all these arcs by hand.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz,tikzpagenodes}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usetikzlibrary{intersections, patterns}
\tcbuselibrary{skins}
\usepackage{lipsum}
\usepackage{xcolor,etoolbox}


\definecolor{titlecolor}{RGB}{199,232,250}

\newcommand{\titlecurve}{
  \path ([yshift=-2pt]title.south west) -- (title.north east) coordinate[pos=-0.1] (BL)
  coordinate[pos=1.1] (TR);
  \path ([yshift=-2pt]title.south east) -- (title.north west) coordinate[pos=-0.1] (BR)
  coordinate[pos=1.1] (TL);
  \fill[titlecolor,ultra thick,rounded corners]
  ([rotate around={-5:(title.center)}]BL) -- 
  ([rotate around={-5:(title.center)}]TL) -- 
  ([rotate around={-5:(title.center)}]TR) --
  ([rotate around={-5:(title.center)}]BR) -- cycle;
    }

\newtcolorbox{oenv}{
  enhanced,
  boxrule=3pt,
  title=Temp title,%
  colframe=titlecolor,
  colback=white,
  coltitle=red,
  attach boxed title to top right={xshift=10pt, yshift=1pt},
  boxed title style={empty},
  underlay boxed title=\titlecurve

}

\begin{document}

\begin{oenv}
  Let $f$ be defined by 
\end{oenv}


\end{document}

enter image description here

With one sharp corner:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz,tikzpagenodes}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usetikzlibrary{intersections, patterns}
\tcbuselibrary{skins}
\usepackage{lipsum}
\usepackage{xcolor,etoolbox}


\definecolor{titlecolor}{RGB}{199,232,250}

\newcommand{\titlecurve}{
  \path ([yshift=-2pt]title.south west) -- (title.north east) coordinate[pos=-0.1] (BL)
  coordinate[pos=1.1] (TR);
  \path ([yshift=-2pt]title.south east) -- (title.north west) coordinate[pos=-0.1] (BR)
  coordinate[pos=1.1] (TL);
  \fill[titlecolor,ultra thick,rounded corners]
  ([rotate around={-5:(title.center)}]BL) -- 
  ([rotate around={-5:(title.center)}]TL) -- 
  ([rotate around={-5:(title.center)}]TR) --
  ([rotate around={-5:(title.center)}]BR) -- ([rotate around={-5:(title.center)}]BL);
    }

\newtcolorbox{oenv}{
  enhanced,
  boxrule=3pt,
  title=Temp title,%
  colframe=titlecolor,
  colback=white,
  coltitle=red,
  attach boxed title to top right={xshift=10pt, yshift=1pt},
  boxed title style={empty},
  underlay boxed title=\titlecurve

}

\begin{document}

\begin{oenv}
  Let $f$ be defined by 
\end{oenv}

enter image description here

2
  • Thanks for the answer, is it possible to make the title.south west corner sharp ? (like in the desired picture)
    – Clifford
    Sep 27, 2018 at 3:30
  • @Clifford Sure, just replace cycle by ([rotate around={-5:(title.center)}]BL). The corresponding corner for the orange box is covered by the bigger box, so it is hard to see that this corner is sharp.
    – user121799
    Sep 27, 2018 at 3:33

You must log in to answer this question.

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