
如何將tcolorbox
的框標題移動到前景(移動到框前面的位置)?正如您在螢幕截圖中看到的(紅色矩形,我的突出顯示),網格與標題重疊,這種行為是不需要的。
\documentclass[]{article}
\usepackage[most]{tcolorbox}
\NewTColorBox{solution}{+O{}}{%
breakable,
enhanced,
sharpish corners,
colframe=blue!50,
colback=white,
coltitle=blue!50,
parbox = false,
fonttitle=\bfseries,
title={Solution},
attach boxed title to top center ={yshift=-\tcboxedtitleheight/2,yshifttext=-\tcboxedtitleheight/2},
halign title=flush center,
boxed title style={%
colback=white,
},
boxrule=0.5mm,top=0mm,bottom=0mm,
underlay={%
\draw[help lines,step=5mm,blue!20!white,shift={(interior.north west)}]
(interior.south west) grid (interior.north east);
},
lowerbox=ignored,
#1
}
\begin{document}
\begin{solution}
Some text
\end{solution}
\end{document}
答案1
使用underlay boxed title
而不是underlay
在添加盒裝標題之前繪製網格,導致盒裝標題出現在前景中(另請參見手冊的第 200 頁tcolorbox
):
\documentclass[]{article}
\usepackage[most]{tcolorbox}
\NewTColorBox{solution}{+O{}}{%
breakable,
enhanced,
sharpish corners,
colframe=blue!50,
colback=white,
coltitle=blue!50,
parbox = false,
fonttitle=\bfseries,
title={Solution},
attach boxed title to top center ={yshift=-\tcboxedtitleheight/2,yshifttext=-\tcboxedtitleheight/2},
halign title=flush center,
boxed title style={%
colback=white,
},
boxrule=0.5mm,top=0mm,bottom=0mm,
underlay boxed title={%
\draw[help lines,step=5mm,blue!20!white,shift={(interior.north west)}]
(interior.south west) grid (interior.north east);
},
lowerbox=ignored,
#1
}
\begin{document}
\begin{solution}
Some text
\end{solution}
\end{document}