我想在链中的最后一个形状上添加一些额外内容(请参见图片以更好地理解)。然而,我遇到了一个意想不到的问题,因为我认为(黑色和红色)线条会连接在一起而没有任何垂直偏移。所以我的问题(希望)很简单:如何解决这个问题?
提前谢谢
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,chains,shapes.symbols}
\begin{document}
\tikzset{
flowEnd/.style={draw, shape=signal, signal from=west, signal to=nowhere},
flowPast/.style={draw, shape=signal, signal from=west},
flowStart/.style={draw, shape=signal, signal to=east},
}
\begin{tikzpicture}[start chain=going right,node distance=2mm]
\node [flowStart,on chain] {Hello};
\node [flowPast,on chain] {World};
\node (end) [flowEnd,on chain] {!};
\draw [red]
let \p1=(end.south east), \p2=(end.north east) in
(\p2) --
($ (\p2) + (10mm,0) $) [rounded corners]--
($ (\p1) + (10mm,0) $) --
(\p1);
\end{tikzpicture}
\end{document}
答案1
在形状样式定义中,您应该添加outer sep=0pt
并定义 common minimum height=...
。完整的、稍微简化的图像代码是:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{calc,
chains,
shapes.symbols}
\tikzset{
base/.style = {draw, shape=signal, on chain,
minimum height=3ex, outer sep=0pt},
flowEnd/.style = {base, signal from=west, signal to=nowhere},
flowPast/.style = {base, signal from=west},
flowStart/.style = {base, signal to=east},
}
\begin{document}
\begin{tikzpicture}[
start chain = going right,
node distance = 2mm ]
%
\node [flowStart] {Hello};
\node [flowPast] {World};
\node (end) [flowEnd] {!};
%
\draw[red]
(end.north east) -- ++ (10mm,0) [rounded corners] |- (end.south east);
\end{tikzpicture}
\end{document}