我正在使用tcolorbox
。在 中tcolorbox
有一个tikzpicture
。通常我会用 为图片添加标题\captionof
。但是,这次我想将标题放在 的侧面tikzpicture
。我该如何在 内部执行此操作tcolorbox
?这是一个工作示例,但标题位于底部。
\documentclass{article}
\usepackage{caption}
\usepackage[many]{tcolorbox}
\newtcolorbox{myboxii}[1][]{
breakable,
freelance,
title=#1,
colback=white,
colbacktitle=white,
coltitle=black,
fonttitle=\bfseries,
bottomrule=0pt,
boxrule=0pt,
colframe=white,
overlay unbroken and first={
\draw[blue!75!black,line width=3pt]
([xshift=5pt]frame.north west) --
(frame.north west) --
(frame.south west);
\draw[blue!75!black,line width=3pt]
([xshift=-5pt]frame.north east) --
(frame.north east) --
(frame.south east);
},
overlay unbroken app={
\draw[blue!75!black,line width=3pt,line cap=rect]
(frame.south west) --
([xshift=5pt]frame.south west);
\draw[blue!75!black,line width=3pt,line cap=rect]
(frame.south east) --
([xshift=-5pt]frame.south east);
},
overlay middle and last={
\draw[blue!75!black,line width=3pt]
(frame.north west) --
(frame.south west);
\draw[blue!75!black,line width=3pt]
(frame.north east) --
(frame.south east);
},
overlay last app={
\draw[blue!75!black,line width=3pt,line cap=rect]
(frame.south west) --
([xshift=5pt]frame.south west);
\draw[blue!75!black,line width=3pt,line cap=rect]
(frame.south east) --
([xshift=-5pt]frame.south east);
},
}
\begin{document}
\begin{myboxii}[Graph ]
\captionsetup{type=figure}
\centering
\begin{tikzpicture}
\node [draw=black] () at (0,0) {};
\end{tikzpicture}
\captionof{figure}{test123}
\label{fig:test}
\end{myboxii}
\end{document}
答案1
我建议使用sidebyside
框的方法,将标题放在左侧,放在上部,将图像放在下部。
\documentclass{article}
\usepackage{caption}
\usepackage[many]{tcolorbox}
\newtcolorbox{myboxii}[2][]{
breakable,
freelance,
title=#2,
colback=white,
colbacktitle=white,
coltitle=black,
fonttitle=\bfseries,
bottomrule=0pt,
boxrule=0pt,
colframe=white,
overlay unbroken and first={
\draw[blue!75!black,line width=3pt]
([xshift=5pt]frame.north west) --
(frame.north west) --
(frame.south west);
\draw[blue!75!black,line width=3pt]
([xshift=-5pt]frame.north east) --
(frame.north east) --
(frame.south east);
},
overlay unbroken app={
\draw[blue!75!black,line width=3pt,line cap=rect]
(frame.south west) --
([xshift=5pt]frame.south west);
\draw[blue!75!black,line width=3pt,line cap=rect]
(frame.south east) --
([xshift=-5pt]frame.south east);
},
overlay middle and last={
\draw[blue!75!black,line width=3pt]
(frame.north west) --
(frame.south west);
\draw[blue!75!black,line width=3pt]
(frame.north east) --
(frame.south east);
},
overlay last app={
\draw[blue!75!black,line width=3pt,line cap=rect]
(frame.south west) --
([xshift=5pt]frame.south west);
\draw[blue!75!black,line width=3pt,line cap=rect]
(frame.south east) --
([xshift=-5pt]frame.south east);
},
#1
}
\begin{document}
\begin{myboxii}[sidebyside,sidebyside align=top seam]{Graph }
\captionof{figure}{test123}%
\label{fig:test}
\tcblower
\centering
\begin{tikzpicture}
\node [draw=black,fill=red] () at (0,0) {};
\end{tikzpicture}%
\end{myboxii}
\end{document}