如何制作如附图所示的偏移边框。这看起来应该很容易用 tikz 完成。我可以使用节点的“double”选项,但我不知道如何继续附加箭头。
添加:
与此同时,我得到了以下结果:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings,arrows}
\begin{document}
\tikzstyle{border_arrow} = [%
decoration={markings,mark=at position 1 with {\arrow[scale=2,line width=.25pt,red!50]{open triangle 60}}}, %
red!50, double distance=4.4pt, shorten >= 9.5pt, shorten <= .45mm, %
line width=.5pt, %
preaction = {decorate}, %
postaction = {draw,line width=4.4pt, white,shorten >= 8.5pt, shorten <= 1pt}]
\tikzstyle{my_node} = [double,double distance=1mm, inner sep=3mm, text width=2.5cm, align=center,line width=.5pt,font=\sffamily\footnotesize\color{white},draw=red!50, fill=red!50]
\begin{tikzpicture}
\node (data1) [my_node] {Commercial Starting Material};
\node [right=of data1] (A) {}; % phantom node to avoid overlapping
\draw[border_arrow] (data1.east|-A.west) -- (A.west);
\node (data2) [right of=A, my_node,xshift=.6cm] {A $\to$ B $\to$ C $\to$ D};
\end{tikzpicture}
\end{document}
如果有人有更简单的方法来实现类似的结果,我很高兴听到这个消息。
答案1
我尝试重现您提供的图像:
我的代码是从头编写的::
\documentclass[tikz,
border=3mm]{standalone}
\usetikzlibrary{calc,
fit,
positioning,
shapes}
\begin{document}
\begin{tikzpicture}[
node distance = 0mm and 12mm,
databox/.style = {inner sep=3mm, text width=2.4cm, align=center, fill=red,
font=\sffamily\footnotesize\bfseries\color{white}
},
arrowbox/.style = {arrow box, arrow box arrows={east:12mm},
arrow box shaft width=5mm, arrow box head extend=3mm,
draw=red, very thick, inner sep=3mm
}
]
\node (data1) [databox] {Commercial Starting Material};
\node (A1) [arrowbox, fit=(data1)] {};
%
\node (data2) [databox, right=of A1.east]
{A $\to$ B $\to$ C $\to$ D};
\node (A2) [arrowbox, fit=(data2)] {};
\end{tikzpicture}
\end{document}
答案2
基于matrix
具有arrowbox
样式并包含databox
节点的替代解决方案。
我以为matrix
节点总是矩形的,但现在我知道它可以容纳shape
我们想要的任何东西。矩阵仅排列内部节点。
总部位于扎科的代码:
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{positioning, shapes}
\begin{document}
\begin{tikzpicture}[
node distance = 0mm and 12mm,
databox/.style = {rectangle, %<---- added
inner sep=3mm, text width=2.4cm,
align=center, fill=red,
font=\sffamily\footnotesize\bfseries\color{white}
},
arrowbox/.style = {arrow box, arrow box arrows={east:12mm},
arrow box shaft width=5mm, arrow box head extend=3mm,
draw=red, very thick, inner sep=3mm,
minimum width=36mm, minimum height=15mm
}
]
\matrix[arrowbox] (A1) {\node[databox] {Commercial Starting Material};\\};
\matrix[arrowbox, right=of A1.east] (A1) {%
\node[databox] {A $\to$ B $\to$ C $\to$ D};\\};
\end{tikzpicture}
\end{document}