我正在尝试使用 tcolorbox 的海报库在背景中绘制一个合适的节点。不幸的是,它没有按预期工作,因为绘图在上面。我尝试使用图层,但它不起作用。
\documentclass[tikz]{standalone}
\usepackage[many,poster]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tcbposter}[
poster = {
height=5cm,
spacing=10mm,
columns=3,
rows=3,
},
coverage={
overlay={
% This does not work because there is a strange
% shift...
% \node[fit=(TCBPOSTER@A)(TCBPOSTER@B),inner sep=3mm,draw=red,fill=red!50!white,opacity=.7] {};
}
}
]
\posterbox{name=A,column=2,row=1}{$A$}
\posterbox{name=B,column=2,row=2}{$B$}
\posterbox{name=C,column=3,row=2}{$C$}
\draw [->] (TCBPOSTER@A) -- (TCBPOSTER@B);
\draw [->] (TCBPOSTER@C) -- (TCBPOSTER@B);
\node[fit=(TCBPOSTER@A)(TCBPOSTER@B),inner sep=3mm,draw=red,fill=red!50!white,opacity=.7] {};
% Bonus if you can make this arrow appear completely without
% manually tweaking coverage/right=2cm.
\draw[->] ([email protected]) -- ++(2cm,0cm);
\end{tcbposter}%
\end{document}
答案1
回答主要问题很简单:在背景层上添加适合节点。
\documentclass{standalone}
\usepackage[many,poster]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{fit,backgrounds}
\begin{document}
\begin{tcbposter}[
poster = {
height=5cm,
spacing=10mm,
columns=3,
rows=3,
},
coverage={
overlay={
% This does not work because there is a strange
% shift...
%\node[fit=(TCBPOSTER@A)(TCBPOSTER@B),inner sep=3mm,draw=red,fill=red!50!white,opacity=.7] {};
}
}
]
\posterbox{name=A,column=2,row=1}{$A$}
\posterbox{name=B,column=2,row=2}{$B$}
\posterbox{name=C,column=3,row=2}{$C$}
\draw [->] (TCBPOSTER@A) -- (TCBPOSTER@B);
\draw [->] (TCBPOSTER@C) -- (TCBPOSTER@B);
\begin{scope}[on background layer]
\node[fit=(TCBPOSTER@A)(TCBPOSTER@B),inner
sep=3mm,draw=red,fill=red!50!white,opacity=.7] {};
\end{scope}
% Bonus if you can make this arrow appear completely without
% manually tweaking coverage/right=2cm.
\draw[->] ([email protected]) -- ++(2cm,0cm);
\end{tcbposter}%
\end{document}
我不明白奖励问题。如果保持大小不变,箭头应该如何放置?