曲線パスをTikZノードに対して平行に表示する

曲線パスをTikZノードに対して平行に表示する

次のような図があります:

ここに画像の説明を入力してください

ノードを水平に揃えてb、その中心を考慮していますが、対称ではなくなるため、c曲線パスに問題が発生します。z

下の図のように、パスの端をz互いに平行にし、ラベルをノードに揃えながら、中央揃えを維持するにはどうすればよいですか?abc

ここに画像の説明を入力してください

コード:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,calc}
\begin{document}
\begin{tikzpicture}[auto,node distance=2cm, align=center,
block/.style={rectangle,draw, thick,inner sep=2pt,minimum size=10mm},
paths/.style={->, very thick, >=stealth'},
curve/.style={<->, thick, >=stealth', bend left=270, looseness=2, distance = 60mm},
]

%Draw, place, and label variables
\node [block] (a) {a};
\node [block] (b) [above right=of a] {bbbbbbbbbb};
\node [block] (c) [below= 4cm of b.south, anchor = north] {ccc};
%\node [block] (c) [below right= of a] {ccc}; % ideal curved path between b and c here, but block not centered

% Draw paths and label them
\draw [paths] (a) to node {x} (b);
\draw [paths] (a) to node [swap] {y} (c);
\draw [curve] (b) to node [swap,midway] {z} (c);
\end{tikzpicture}
\end{document}

答え1

次の例では、まず「z」のノードをzノードの左側に配置してa、「z」を「a」と同じベースラインに配置します。次に、曲線をノードからb.westz.eastz.eastの2 つの部分に分割しますc.west。コンポーネントとにより.west.east開始点と終了点が正確になります。曲線部分の開始角度と終了角度は、パス演算子 のオプションinとで指定します。これにはライブラリ が必要です。outtotopaths

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,calc,topaths}
\begin{document}
\begin{tikzpicture}[auto,node distance=2cm, align=center,
  block/.style={rectangle,draw, thick,inner sep=2pt,minimum size=10mm},
  paths/.style={->, very thick, >=stealth'},
  curve/.style={<->, thick, >=stealth'},
]

%Draw, place, and label variables
\node [block] (a) {a};
\node [block] (b) [above right=of a] {bbbbbbbbbb};
\node [block] (c) [below= 4cm of b.south, anchor = north] {ccc};
%\node [block] (c) [below right= of a] {ccc}; % ideal curved path between b
%and c here, but block not centered

% Draw paths and label them
\draw [paths] (a) to node {x} (b);
\draw [paths] (a) to node [swap] {y} (c);
\node [xshift=-3em, anchor=base east] (z) at (a.base west) {z};
\draw [curve] (b.west) to[out=180, in=90] (z.east)
                  to[out=-90, in=180] (c.west);
\end{tikzpicture}
\end{document}

結果

(a) -- (b)直線接続と(a) -- (c)角で接続されたバリエーションもあります。この場合は見た目が良くなるかもしれません。

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,calc,topaths}
\begin{document}
\begin{tikzpicture}[auto,node distance=2cm, align=center,
  block/.style={rectangle,draw, thick,inner sep=2pt,minimum size=10mm},
  paths/.style={->, very thick, >=stealth'},
  curve/.style={<->, thick, >=stealth'},
]

%Draw, place, and label variables
\node [block] (a) {a};
\node [block] (b) [above right=of a] {bbbbbbbbbb};
\node [block] (c) [below= 4cm of b.south, anchor = north] {ccc};
%\node [block] (c) [below right= of a] {ccc}; % ideal curved path between b
%and c here, but block not centered

% Draw paths and label them
\draw [
  paths,
  shorten <=-.7\pgflinewidth,
] (a.north east) to node {x} (b.south west);
\draw [
  paths,
  shorten <=-.7\pgflinewidth,
] (a.south east) to node [swap] {y} (c.north west);
\node [xshift=-3em, anchor=base east] (z) at (a.base west) {z};
\draw [curve] (b.west) to[out=180, in=90] (z.east)
                  to[out=-90, in=180] (c.west);
\end{tikzpicture}
\end{document}

結果バリアントコーナー

関連情報