
Tikz で作成したネットワークがあります。グラフには 3 層のノードがあります。ノードを接続する点線を描画し、右端のノード ($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
ようこそ!こんな感じですか? を使用して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}