我将下面的代码用于一些文本,但每个段落都缺少起始间距。我希望红色箭头处的起始间距与蓝色箭头处的起始间距一样。
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage{varwidth}
\newtcolorbox{mybox}[2][]{enhanced,
before skip=2mm,after skip=2mm, colback=black!5,colframe=black!50,boxrule=0.2mm,
attach boxed title to top left={xshift=1cm,yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm,
boxed title style={frame code={
\path[fill=tcbcolback!30!black]
([yshift=-1mm,xshift=-1mm]frame.north west)
arc[start angle=0,end angle=180,radius=1mm]
([yshift=-1mm,xshift=1mm]frame.north east)
arc[start angle=180,end angle=0,radius=1mm];
\path[left color=tcbcolback!60!black,right color=tcbcolback!60!black,
middle color=tcbcolback!80!black]
([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east)
[rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east)
-- (frame.south east) -- (frame.south west)
-- ([xshift=-1mm,yshift=-1mm]frame.north west)
[sharp corners]-- cycle;
},interior engine=empty,
},
fonttitle=\bfseries,
title={#2},#1}
\begin{document}
\begin{mybox}[colbacktitle=green]{My title}
\lipsum[1-2]
\end{mybox}
\end{document}
提前致谢!!!
答案1
尝试一下这个方法:
(添加,before upper={\parindent15pt},
颜色框的定义)
\documentclass{article}
\usepackage[most]{tcolorbox}
\definecolor{tcbcolback}{RGB}{100,100,100}
\usepackage{lipsum}
\usepackage{varwidth}
\newtcolorbox{mybox}[2][]{enhanced,
before skip=2mm,after skip=2mm, colback=black!5,colframe=black!50,boxrule=0.2mm,
attach boxed title to top left={xshift=1cm,yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm,
boxed title style={frame code={
\path[fill=tcbcolback!30!black]
([yshift=-1mm,xshift=-1mm]frame.north west)
arc[start angle=0,end angle=180,radius=1mm]
([yshift=-1mm,xshift=1mm]frame.north east)
arc[start angle=180,end angle=0,radius=1mm];
\path[left color=tcbcolback!60!black,right color=tcbcolback!60!black,
middle color=tcbcolback!80!black]
([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east)
[rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east)
-- (frame.south east) -- (frame.south west)
-- ([xshift=-1mm,yshift=-1mm]frame.north west)
[sharp corners]-- cycle;
},interior engine=empty,
},before upper={\parindent15pt},
fonttitle=\bfseries,
title={#2},#1}
\begin{document}
\begin{mybox}[colbacktitle=green]{My title}
\lipsum[1-2]
\end{mybox}
\end{document}
PS:如果这对你有用,你可以将你的帖子标记为重复这个问题/答案