두 개의 다른 노드 위에 중심에 노드를 배치하는 방법은 무엇입니까?
Aug 20 2020
두 개의 노드가 있고 그 위에 세 번째 노드를 배치하고 싶습니다. 아래 예에서 노드 Z의 수직 위치가 좋습니다. 그러나 노드 Z를 아래쪽에있는 두 노드를 기준으로 중앙에 오도록 오른쪽으로 더 이동하고 싶습니다. 이와 유사한 보간 명령 above=of x!0.5!y
이나 다른 간단한 방법이 있습니까?
예:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,fit,calc,backgrounds,shapes.geometric}
\begin{document}
\begin{tikzpicture}
\node[circle, draw=black] (x) {$x$};
\node[circle, draw=black, right=of x] (y) {$y$};
\node[circle, draw=black, above=of x] (z) {$z$};
\path (x) edge[->, sloped, anchor=south] node {left} (z);
\path (z) edge[->, sloped, anchor=south] node {right} (y);
\path (x) edge[->, sloped, anchor=north] node {bottom} (y);
\end{tikzpicture}
\end{document}
산출:

2 다른 노드 아래 의 관련 질문 tikz center node를 알고 있지만 답변은 right above=x
실제로 X와 Y 사이의 노드를 중앙에 배치하지 않는 것을 제안 하는 것 같습니다 .
답변
4 Zarko Aug 20 2020 at 01:26
이렇게 :

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
calc,
positioning,
quotes}
\begin{document}
\begin{tikzpicture}[
node distance = 13mm,
C/.style = {%C: as circle
circle, draw, minimum size=1.5em, inner sep=2pt},
every edge/.style = {draw, -Straight Barb},
every edge quotes/.style = {auto, font=\footnotesize, inner sep=1pt, sloped}
]
\node[C] (x) {$x$};
\node[C, right=of x] (y) {$y$};
\node[C, above=of $(x.north)!0.5!(y.north)$] (z) {$z$};
\path (x) edge["left"] (z)
(z) edge["right"] (y)
(x) edge["bottom"] (y);
\end{tikzpicture}
\end{document}
1 AndréC Aug 20 2020 at 01:40
on grid
옵션이있는 또 다른 방법 .

\documentclass[border=5mm,tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\begin{scope}[on grid,node distance=2cm]
\draw[help lines](-1,-1) grid(3,3);%<-- comment this line to hide the grid
\node[circle, draw=black] (x) {$x$};
\node[circle, draw=black, right=of x] (y) {$y$};
\node[circle, draw=black, above right=2cm and 1cm of x] (z) {$z$};
\end{scope}
\path (x) edge[->, sloped, anchor=south] node {left} (z);
\path (z) edge[->, sloped, anchor=south] node {right} (y);
\path (x) edge[->, sloped, anchor=north] node {bottom} (y);
\end{tikzpicture}
\end{document}