newtcolorbox 到 tcbset

newtcolorbox 到 tcbset

来自前一个主题:带线的样式框

我想在 tcbposter 中使用这个框,我将其更改为 tcbset (mystyle),但不工作

最小工作代码:

\documentclass{article}
\usepackage[left=1.0cm,right=0.3cm,top=0.5cm,bottom=0.5cm]{geometry}
\usepackage[most]{tcolorbox}
\tcbuselibrary{poster}
\newcounter{ic}
\usepackage{xcolor}
\usepackage{lipsum}
\newtcolorbox{Mybox}[2][]{%
enhanced,top=0mm,left=2pt,right=2pt,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
  overlay unbroken and first={%
  \draw[fill=yellow]
   ([xshift=6pt,yshift=12pt]frame.north west) -| ++ (1,-2) 
   -- ++ (-0.5,0.3) -- ++ (-0.5,-0.3) -- cycle;
  \node[anchor=north west,text width=1cm-4pt,align=center] at ([xshift=6pt,yshift=12pt]frame.north west) 
  {#2}; 
},
breakable,arc=4mm,
%colframe=blue!80!red,colback=white,
width=\textwidth, 
before upper ={\parshape 5
1.2cm \dimexpr \hsize-1.2cm\relax
1.2cm \dimexpr \hsize-1.2cm\relax
1.2cm \dimexpr \hsize-1.2cm\relax
1.2cm \dimexpr \hsize-1.2cm\relax
0pt \hsize} ,#1}

\tcbset{
        mystyle/.style 2 args={%
        enhanced,top=0mm,left=2pt,right=2pt,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
  overlay unbroken and first={%
  \draw[fill=yellow]
   ([xshift=6pt,yshift=12pt]frame.north west) -| ++ (1.6,-1.3) 
   -- ++ (-0.8,0.3) -- ++ (-0.8,-0.3) -- cycle;
  \node[anchor=north west,text width=1.6cm-4pt,align=center] at ([xshift=6pt,yshift=12pt]frame.north west) 
  {#2}; 
},
breakable,arc=4mm,
width=\textwidth,#1
%},
        #1,
    }
}

\begin{document}
\begin{Mybox}[width=5.4cm]{abc xyz}
some text some text some text some text some text some text some text some text

\end{Mybox}

\begin{tcbposter}[ poster = {columns=1, rows=3, height=14cm,width=12cm }]

%  \posterbox[colframe = red]{name=A}{\lipsum[1]}
\posterbox[colframe = red,height=5.0cm,width =4.3cm]{name=A}{abc xyz}
\posterbox[height=5.0cm,width =4.0cm, mystyle={colframe=red}{abc}]{xshift=1cm, yshift=-5cm}{xyz}
{some text some text some text some text some text some text some text some text}
\end{tcbposter}
\end{document}

请帮助更改“tcbset - mystyle”:可以更改此框的 colframe、名称和 xy 位置、高度和宽度。

预先感谢

答案1

像这样吗?

\documentclass{article}
\usepackage[left=1.0cm,right=0.3cm,top=0.5cm,bottom=0.5cm]{geometry}
\usepackage[most]{tcolorbox}
\tcbuselibrary{poster}
\newcounter{ic}
\usepackage{xcolor}
\usepackage{lipsum}
\newtcolorbox{Mybox}[2][]{%
enhanced,top=0mm,left=2pt,right=2pt,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
  overlay unbroken and first={%
  \draw[fill=yellow]
   ([xshift=6pt,yshift=12pt]frame.north west) -| ++ (1,-2) 
   -- ++ (-0.5,0.3) -- ++ (-0.5,-0.3) -- cycle;
  \node[anchor=north west,text width=1cm-4pt,align=center] at ([xshift=6pt,yshift=12pt]frame.north west) 
  {#2}; 
},
breakable,arc=4mm,
%colframe=blue!80!red,colback=white,
width=\textwidth, 
before upper ={\parshape 5
1.2cm \dimexpr \hsize-1.2cm\relax
1.2cm \dimexpr \hsize-1.2cm\relax
1.2cm \dimexpr \hsize-1.2cm\relax
1.2cm \dimexpr \hsize-1.2cm\relax
0pt \hsize} ,#1}

\tcbset{mystyle/.style 2 args={%
        enhanced,top=0mm,left=2pt,right=2pt,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
  overlay unbroken and first={%
  \draw[fill=yellow]
   ([xshift=6pt,yshift=12pt]frame.north west) -| ++ (1.6,-1.3) 
   -- ++ (-0.8,0.3) -- ++ (-0.8,-0.3) -- cycle;
  \node[anchor=north west,text width=1.6cm-4pt,align=center] at ([xshift=6pt,yshift=12pt]frame.north west) 
  {#2}; 
},
breakable,arc=4mm,
before upper ={\parshape 3
1.8cm \dimexpr \hsize-1.8cm\relax
1.8cm \dimexpr \hsize-1.8cm\relax
0pt \hsize},#1
}}

\begin{document}
\begin{Mybox}[width=5.4cm]{abc xyz}
some text some text some text some text some text some text some text some text

\end{Mybox}
% 
\begin{tcbposter}[ poster = {columns=1, rows=3, height=14cm,width=12cm }]
% 
% %  \posterbox[colframe = red]{name=A}{\lipsum[1]}
\posterbox[colframe = red,height=5.0cm,width =8.3cm]{name=A}{abc xyz}
\posterbox[height=5.0cm,width =4.0cm, mystyle={colframe=red}{abc}]{xshift=1cm,
yshift=-5cm}%{xyz}
{some text some text some text some text some text some text some text some text}
\end{tcbposter}
\end{document}

在此处输入图片描述

相关内容