帮忙复制这个盒子吗?

帮忙复制这个盒子吗?

我正在尝试重现这个框,但标题框放在右上角并稍微旋转。

我对结果不满意:左右边框不太平行,角的圆角也不同。你能帮帮我吗? 我想要的是 我懂了

% 代码

\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

您只需移动坐标,但我想说的是,围绕标题框的中心旋转它们看起来更好。而且rounded corners免去了您手动添加所有这些圆弧的麻烦。

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

在此处输入图片描述

有一个尖角:

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

在此处输入图片描述

相关内容