![使用阴影上的拟合节点来包含阴影](https://linux22.com/image/358261/%E4%BD%BF%E7%94%A8%E9%98%B4%E5%BD%B1%E4%B8%8A%E7%9A%84%E6%8B%9F%E5%90%88%E8%8A%82%E7%82%B9%E6%9D%A5%E5%8C%85%E5%90%AB%E9%98%B4%E5%BD%B1.png)
我使用了双重复制阴影(来自这个答案) 向节点添加多个矩形。我现在想用适合节点包裹该节点和其他几个节点,但似乎适合节点不包含阴影。
例如:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows,positioning,calc,fit}
\tikzset{multiple/.style = {double copy shadow={shadow xshift=1ex,shadow
yshift=-1.5ex,draw=black!30},fill=white,draw=black,thick,minimum height = 1cm,minimum
width=2cm},
ordinary/.style = {rectangle,draw,thick,minimum height = 1cm,minimum width=2cm}}
\begin{document}
\begin{tikzpicture}
\node [ordinary] at (0,0) (a) {Some};
\node [multiple,below=3cm of a] (b) {Text};
\draw[-latex] (a) -- coordinate (ab) (b);
\draw (ab) -- ++(0.7,-0.5)coordinate[pos=.3](ab1) coordinate[pos=.6](ab2);
\draw[-latex] (ab1) -- ($(b.north west)!(ab1)!(b.north east)$);
\draw[-latex] (ab2) -- ($(b.north west)!(ab2)!(b.north east)$);
\node [fit=(a)(b),draw,rectangle] {};
\end{tikzpicture}
\end{document}
结果是:
是否可以修改代码来包含它们?
答案1
如果已知由于阴影导致占用率增加,则可以定义一种fit shadow
增加的样式x|y sep
以包含阴影。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows,positioning,calc,fit}
\tikzset{%
multiple/.style = {%
double copy shadow={%
shadow xshift=1ex,
shadow yshift=-1.5ex,
draw=black!30},
fill=white,
draw=black,
thick,
minimum height = 1cm,
minimum width=2cm},
ordinary/.style = {%
rectangle,
draw,
thick,
minimum height = 1cm,
minimum width=2cm},
fit shadow/.style = {%
fit = #1,
inner xsep=2ex+.3333em,
inner ysep=3ex+.3333em}
}
\begin{document}
\begin{tikzpicture}
\node [ordinary] at (0,0) (a) {Some};
\node [multiple, below=3cm of a] (b) {Text};
\draw[-latex] (a) -- coordinate (ab) (b);
\draw (ab) -- ++(0.7,-0.5)coordinate[pos=.3](ab1) coordinate[pos=.6](ab2);
\draw[-latex] (ab1) -- ($(b.north west)!(ab1)!(b.north east)$);
\draw[-latex] (ab2) -- ($(b.north west)!(ab2)!(b.north east)$);
\node [fit shadow=(a)(b), draw, rectangle] {};
\end{tikzpicture}
\end{document}
或者,也可以将所需的阴影角包含在fit
列表中:
\node [fit={(a)([shift={(2ex,-3ex)}]b.south east)}, draw, rectangle] {};