我想在鏈中的最後一個形狀上添加一些額外的內容(請參閱圖片以更好地理解)。然而,我遇到了一個意想不到的問題,因為我認為(黑色和紅色)線會連接而沒有任何垂直偏移。所以我的問題(希望)是一個簡單的問題:如何解決這個問題?
提前謝謝
\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}