
다음과 같은 다이어그램이 있습니다.
b
노드 와 중심을 수평으로 정렬했지만 더 이상 대칭이 아니기 때문에 c
곡선 경로에 문제가 발생합니다 .z
아래 다이어그램과 같이 경로의 끝을 z
서로 평행하게 만들고 레이블을 node 와 정렬 하면서 여전히 중앙 에 정렬되도록 하려면 어떻게 해야 합니까?a
b
c
암호:
\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
다음 예에서는 먼저 "a"와 동일한 기준선에 "z"를 가져오기 위해 "z" z
에 대한 노드를 노드 왼쪽에 배치합니다. a
그런 다음 곡선은 노드에서 , 로 두 부분 b.west
으로 분할 z.east
됩니다 . 구성 요소는 올바른 시작점과 끝점을 보장합니다. 곡선 부분의 시작 및 끝 각도는 옵션 및 경로 연산자 에 의해 지정됩니다 . 여기에는 라이브러리가 필요합니다 .z.east
c.west
.west
.east
in
out
to
topaths
\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}