
重複の可能性あり:
写真に特別な線を描く方法
以下のコードを使用して図を描画しますが、線は s2 から s4 まで直線になります (画像を参照)。
しかし、私は写真の赤い線のような角度の線が欲しいです。誰かやり方を教えてくれませんか?
\usepackage{tikz}
\usetikzlibrary{trees}
\resizebox{.5\textwidth}{!}{
\tikzset{level 1/.style={level distance=0.7cm, sibling distance=3cm}}
\tikzset{level 2/.style={level distance=0.7cm, sibling distance=6cm}}
\tikzset{bag/.style={text centered,yshift=-0.2cm}}
\begin{tikzpicture}[grow=down, -stealth]
\node[bag]{$S_0{:}(B,true,0)$}
child{ edge from parent node[right]{$\lsInvoke \_ DS$}; \node[bag]{$S_1{:}(R_{good})$}
child{ edge from parent node[right]{and}; \node[bag]{$S_2{:}(and)$}
child[missing]
child{ edge from parent node[right=0.1cm]{$[else]$}; \node[bag]{$S_3{:}(A_1)$}
}
child{ edge from parent node[right=0.9cm]{$[if]$}; \node[bag]{$S_4{:}(R_{good})$}
}
}
};
\end{tikzpicture}}
答え1
あなたのコードをコンパイルできませんし、パスを描画するツリーの経験もありません。ただし、これはあなたが探していると思われる概念を示すはずです:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (5,-1);
\draw (A) -- (B);
\draw[thick,dashed,red,->] (A) -| (B);
\end{tikzpicture}
\end{document}
これにより、次のようになります。
ここで最も重要なのは、 の代わりに を使用して、標準の座標系ではなく直線座標系でパスを作成することです-|
。draw--
と一緒に使用すると、直線を描画する代わりに、その線のコンポーネントを描画します。
おそらく、S_2 と S_4 に名前付き座標を作成し、その上に直線パスを重ねるだけでよいのではないでしょうか。