代码来自这很好的答案,我该如何修改它以使所有框架都变成圆角?我设法将主框架弄圆了,但其他两个仍然是直的:
\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --
\tcbset{
titlecommon/.style={
fontupper=\Large\bfseries\sffamily,
top=2mm,
bottom=2mm,
halign=center,
sharp corners,
leftrule=0.5mm, %to draw left side in subtitle box
rightrule=0.5mm, %to draw right side in subtitle box
opacityfill=.5, %to test subtitles geometry and positioning
},
toptitle/.style={
titlecommon,
colframe=green,
colback=green!20,
},
bottomtitle/.style={
titlecommon,
colframe=red,
colback=red!20,
},
}
\newtcolorbox{twotitle}[3][]{
enhanced,
arc=5pt,
% sharp corners,
colback=white,
colframe=black!75,
notitle,
before upper={\tcbsubtitle[toptitle]{#2}},
after upper={\tcbsubtitle[bottomtitle]{#3}},
top=-1.5mm, %-boxsep-toprule
bottom=-1.5mm, %-boxsep-bottomrule
#1,
}
\begin{document}
\begin{twotitle}[colback=orange!20]{Title}{Test}
\lipsum[1]
\end{twotitle}
\end{document}
答案1
经过一些调整
\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --
\tcbset{
titlecommon/.style={
fontupper=\Large\bfseries\sffamily,
top=2mm,
bottom=2mm,
halign=center,
sharp corners,
leftrule=0.5mm, %to draw left side in subtitle box
rightrule=0.5mm, %to draw right side in subtitle box
opacityfill=1, %to test subtitles geometry and positioning
arc=5pt,
},
toptitle/.style={
titlecommon,
colframe=green,
colback=green!20,
rounded corners=north,
},
bottomtitle/.style={
titlecommon,
colframe=red,
colback=red!20,
rounded corners=south,
},
}
\newtcolorbox{twotitle}[3][]{
arc=5pt,
enhanced,
% sharp corners,
colback=white,
colframe=black!75,
notitle,
before upper={\tcbsubtitle[toptitle]{#2}},
after upper={\tcbsubtitle[bottomtitle]{#3}},
top=-1.5mm, %-boxsep-toprule
bottom=-1.5mm, %-boxsep-bottomrule
#1,
}
\begin{document}
\begin{twotitle}[colback=orange!20]{Title}{Test}
\lipsum[1]
\end{twotitle}
\end{document}