
Tikz에서 만든 네트워크가 있습니다. 그래프에는 세 가지 계층의 노드가 있습니다. 노드를 연결하는 점선을 그리고 가장 오른쪽 노드($m_1$, $j$ 및 $i$)(계층 1, 2, 3) 옆에 계층 레이블을 배치해야 합니다.
\documentclass[]{report}
\usepackage{tikz}
\usetikzlibrary{arrows, automata, arrows.meta, positioning, calc}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}[
> = stealth, % arrow head style
shorten > = 1pt, % don't touch arrow head to node
auto,
node distance = 3cm, % distance between nodes
semithick % line style
]
\tikzstyle{every state}=[
draw = black,
thick,
fill = white,
minimum size = 4mm
]
\node [dashed, state] (a) {$i$};
\node[state] (b) at ($ (a) + (45:1.5) $) {$j$};
\node[dashed, state] (c) at ($ (a) + (135:1.5) $) {$k$};
\node[state] (d) at ($ (c) + (45:2.1) $) {$m_1$};
\node[dashed, state] (e) at ($ (c) + (90:1.5) $) {$m_2$};
\node[state] (d1) at ($ (c) + (135:2.1) $) {$m_3$};
\path[->] (d) edge node {} (c);
\path[->] (d1) edge node {} (c);
\path[dashed,->] (e) edge node {} (c);
\path[->] (b) edge node {} (a);
\path[dashed, ->] (c) edge node {} (a);
\end{tikzpicture}
\label{fig:assembly-eg}
\end{figure}
\end{document}
답변1
환영! 이 같은? a를 사용하여 local bounding box
계층 레이블을 정렬 할 수 있습니다 . 또한 더 \tikzstyle
이상 사용되지 않습니다.
\documentclass[]{report}
\usepackage{tikz}
\usetikzlibrary{automata, arrows.meta, positioning, calc}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}[
> = stealth, % arrow head style
shorten > = 1pt, % don't touch arrow head to node
auto,
node distance = 3cm, % distance between nodes
semithick % line style
]
\begin{scope}[local bounding box=tree,every state/.style={draw = black,thick,
fill = white,minimum size = 4mm}]
\node [dashed, state] (a) {$i$};
\node[state] (b) at ($ (a) + (45:1.5) $) {$j$};
\node[dashed, state] (c) at ($ (a) + (135:1.5) $) {$k$};
\node[state] (d) at ($ (c) + (45:2.1) $) {$m_1$};
\node[dashed, state] (e) at ($ (c) + (90:1.5) $) {$m_2$};
\node[state] (d1) at ($ (c) + (135:2.1) $) {$m_3$};
\path ([xshift=1em]tree.east); %<-increase local bounding box
\end{scope}
\draw[dotted] (d1) -- (e) -- (d) -- (d-|tree.east) node[right]{1};
\draw[dotted] (c) -- (b) -- (b-|tree.east) node[right]{2};
\draw[dotted] (a) -- (a-|tree.east) node[right]{3};
\path[->] (d) edge node {} (c);
\path[->] (d1) edge node {} (c);
\path[dashed,->] (e) edge node {} (c);
\path[->] (b) edge node {} (a);
\path[dashed, ->] (c) edge node {} (a);
\end{tikzpicture}
\label{fig:assembly-eg}
\end{figure}
\end{document}