
Tikz를 사용하여 다음 다이어그램을 만들었습니다. 어쨌든 제대로 표시할 수 있습니까? (그대로 마지막 노드 아래 노드까지 다 같이 보여서 엉망이네요)
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{io} = [ellipse, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=2cm]
\node (1) [io] {1 1 1 1};
\node (2) [io, below of=1] {2 1 0 1};
\node (3) [io, below of=2] {1 0 1 2};
\node (4) [io, below of=3] {2 0 0 2};
\node (5) [io, below of=4] {0 0 2 2};
\node (6) [io, below of=5] {0 1 2 1};
\node (7) [io, below of=6] {0 2 2 0};
\node (8) [io, below of=7] {1 2 1 0};
\node (9) [io, below of=8] {2 2 0 0};
\draw [arrow] (1) -- node {t1} (2);
\draw [arrow] (2) -- node {t2} (3);
\draw [arrow] (3) -- node {t1} (4);
\draw [arrow] (4) -- node {t3} (2);
\draw [arrow] (3) -- node {t3} (1);
\draw [arrow] (2) -- node {t3} (9);
\draw [arrow] (9) -- node {t2} (1);
\draw [arrow] (1) -- node {t3} (8);
\draw [arrow] (1) -- node {t2} (5);
\draw [arrow] (5) -- node {t1} (3);
\draw [arrow] (5) -- node {t3} (6);
\draw [arrow] (6) -- node {t1} (1);
\draw [arrow] (6) -- node {t3} (7);
\draw [arrow] (7) -- node {t1} (8);
\draw [arrow] (8) -- node {t2} (6);
\draw [arrow] (8) -- node {t1} (9);
\end{tikzpicture}
\end{document}
예를 들어, 원 레이아웃으로 노드를 표시하려면 어떻게 해야 합니까?
답변1
"원형 레이아웃"이라고 말씀하셨는데요. 여기에 예가 있습니다. 매크로를 사용하여 노드 (1) 주위에 노드를 배치할 수 있습니다 at (<angle:distance>)
.
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{io} = [ellipse, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}%[node distance=2cm]
\node (1) [io] {1 1 1 1};
\node (2) [io] at (45:2in) {2 1 0 1};
\node (4) [io] at (90:2in) {2 0 0 2};
\node (3) [io] at (135:2in) {1 0 1 2};
\node (5) [io] at (180:2in) {0 0 2 2};
\node (6) [io] at (225:2in) {0 1 2 1};
\node (7) [io] at (270:2in) {0 2 2 0};
\node (8) [io] at (315:2in) {1 2 1 0};
\node (9) [io] at (360:2in) {2 2 0 0};
\draw [arrow] (1) -- node[auto] {t1} (2); %% note auto option here onwards
%% for proper placement.
\draw [arrow] (2) -- node[auto] {t2} (3);
\draw [arrow] (3) -- node[auto] {t1} (4);
\draw [arrow] (4) -- node[auto,xshift=1cm] {t3} (2);
\draw [arrow] (3) -- node[auto] {t3} (1);
\draw [arrow] (2) -- node[auto] {t3} (9);
\draw [arrow] (9) -- node[auto] {t2} (1);
\draw [arrow] (1) -- node[auto] {t3} (8);
\draw [arrow] (1) -- node[auto] {t2} (5);
\draw [arrow] (5) -- node[auto] {t1} (3);
\draw [arrow] (5) -- node[auto] {t3} (6);
\draw [arrow] (6) -- node[auto] {t1} (1);
\draw [arrow] (6) -- node[auto] {t3} (7);
\draw [arrow] (7) -- node[auto] {t1} (8);
\draw [arrow] (8) -- node[auto] {t2} (6);
\draw [arrow] (8) -- node[auto] {t1} (9);
\end{tikzpicture}
\end{document}
필요에 맞게 토폴로지를 직접 조정할 수 있습니다.
답변2
다음은 구문 사용을 시작 하고 화살표의 to
앵커와 각도를 지정하는 데 in=
도움 이 되는 내용입니다.out=
암호:
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{io} = [ellipse, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=2cm]
\node (1) [io] {1 1 1 1};
\node (2) [io, below of=1] {2 1 0 1};
\node (3) [io, below of=2] {1 0 1 2};
\node (4) [io, below of=3] {2 0 0 2};
%\node (5) [io, below of=4] {0 0 2 2};
%\node (6) [io, below of=5] {0 1 2 1};
%\node (7) [io, below of=6] {0 2 2 0};
%\node (8) [io, below of=7] {1 2 1 0};
%\node (9) [io, below of=8] {2 2 0 0};
\draw [arrow] (1.south) -- node[right] {t1} (2.north);
\draw [arrow] (2.south) -- node[right] {t2} (3.north);
\draw [arrow] (3.south) -- node[right] {t1} (4.north);
\draw [arrow,out=70,in=-70] (4.east) to node[right] {t3} (2.east);
\draw [arrow,out=170,in=-170] (3.west) to node[left] {t3} (1.west);
%\draw [arrow] (2.south) -- node[right] {t3} (9.north);
%\draw [arrow] (9.south) -- node[right] {t2} (1.north);
%\draw [arrow] (1.south) -- node[right] {t3} (8.north);
%\draw [arrow] (1.south) -- node[right] {t2} (5.north);
%\draw [arrow] (5.south) -- node[right] {t1} (3.north);
%\draw [arrow] (5.south) -- node[right] {t3} (6.north);
%\draw [arrow] (6.south) -- node[right] {t1} (1.north);
%\draw [arrow] (6.south) -- node[right] {t3} (7.north);
%\draw [arrow] (7.south) -- node[right] {t1} (8.north);
%\draw [arrow] (8.south) -- node[right] {t2} (6.north);
%\draw [arrow] (8.south) -- node[right] {t1} (9.north);
\end{tikzpicture}
\end{document}