![如何将 tcolorbox 放在整张图片周围?](https://linux22.com/image/458056/%E5%A6%82%E4%BD%95%E5%B0%86%20tcolorbox%20%E6%94%BE%E5%9C%A8%E6%95%B4%E5%BC%A0%E5%9B%BE%E7%89%87%E5%91%A8%E5%9B%B4%EF%BC%9F.png)
有了这段代码,我修改了一下:
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{tikzrput}
\usepackage[object=vectorian]{pgfornament}
\newtcolorbox{frameT}{enhanced, colframe=black,colback=gray!5, boxrule=2pt,arc=6pt,outer arc=60pt,frame hidden, after skip = -12pt, interior style={left color = orange, bottom color = purple}, opacityback = 0.06}
\begin{document}
\begin{frameT} % Frame not around whole picture
\begin{center}
\begin{picture}(0,0)%
\rput(0,0){\Huge Title}%
\rput[t](0,-1){\pgfornament[width=7cm]{75}}
\rput(-0.05,-4){\Large Name}%
\rput[l](-2.6,-4){\pgfornament[width=1cm]{3}}%
\rput[r](2.6,-4){\pgfornament[width=1cm,symmetry=v]{3}}%
\end{picture}
\end{center}
\end{frameT}
\end{document}
它提供了一幅漂亮的装饰画,然而彩色盒子没有完全封闭。
我如何实现这个目标?
答案1
通过使用,\begin{picture}(0,0)
您基本上将图片的大小设置为 0。您可以为图片选择合适的大小(可能需要更改一些坐标...)或者,作为快速破解,使用图片周围的小页面手动添加一些高度:
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{tikzrput}
\usepackage[object=vectorian]{pgfornament}
\newtcolorbox{frameT}{
enhanced, colframe=black,colback=gray!5, boxrule=2pt,arc=6pt,outer arc=60pt,frame hidden, after skip = -12pt, interior style={left color = orange, bottom color = purple}, opacityback = 0.06
}
\begin{document}
\begin{frameT} % Frame not around whole picture
\begin{minipage}[t][5cm]{\textwidth}
\centering
\vskip0.5cm
\begin{picture}(0,0)%
\rput(0,0){\Huge Title}%
\rput[t](0,-1){\pgfornament[width=7cm]{75}}
\rput(-0.05,-4){\Large Name}%
\rput[l](-2.6,-4){\pgfornament[width=1cm]{3}}%
\rput[r](2.6,-4){\pgfornament[width=1cm,symmetry=v]{3}}%
\end{picture}
\end{minipage}
\end{frameT}
\end{document}