![\draw[->] で tikz を使用して丸い角をより適切に使用する](https://rvso.com/image/392369/%5Cdraw%5B-%3E%5D%20%E3%81%A7%20tikz%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E4%B8%B8%E3%81%84%E8%A7%92%E3%82%92%E3%82%88%E3%82%8A%E9%81%A9%E5%88%87%E3%81%AB%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B.png)
次のようなコードがあります:
% !TeX encoding = UTF-8
\documentclass[utf8]{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\newcommand{\multilinks}[3]{\foreach \noeud in {#1} {\draw[<-, rounded corners] (#2.west) -| ++(-#3em,0em) |- (\noeud.east);}}
\begin{document}
\begin{figure}[htp]
\centering
\tikzset{
basic/.style={draw, rounded corners=2pt, thick, text width=8em, align=flush center, node distance=2em},
}
\begin{tikzpicture}[]
\matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
\node(n1){Text}; & \node(n3){another text}; \\
\node(n2){one thing}; & \node(n4){again text}; \\
};
\multilinks{n1,n2}{n3}{3}
\multilinks{n1}{n4}{1}
\end{tikzpicture}
\end{figure}
\end{document}
次のような結果が得られます:
ご覧のとおり、曲線が変です。どうすれば修正できますか?
私が望む結果は次のとおりです。
答え1
の定義と最初の\multilinks
リストに若干の変更があります:#1
\multilinks
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix,positioning}
\newcommand{\multilinks}[3]{
\foreach \noeud in {#1} {
\draw[<-, rounded corners] (#2.west) -- ++(-#3 em,0em) |- (\noeud.east);
}
}
\begin{document}
\tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
}
}
\begin{tikzpicture}[]
\fontsize{8}{9} \selectfont
\matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
\node(n1){Text}; & \node(n3){another text}; \\
\node(n2){one thing}; & \node(n4){again text}; \\
};
\multilinks{n2}{n3}{3}
\multilinks{n1}{n4}{1}
\end{tikzpicture}
\end{document}
編集
元の方法を維持したい場合、 の定義は\multilinks
もう少し複雑になります。
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix,positioning}
\newcommand{\multilinks}[3]{
\begin{scope}[x=1em,y=1em]
\newdimen\xend
\newdimen\yend
\path (#2.west);
\pgfgetlastxy{\xend}{\yend}
\foreach \i in {#1} {
\newdimen\xstart
\newdimen\ystart
\path (\i.east);
\pgfgetlastxy{\xstart}{\ystart}
\coordinate (1) at ({\xend-#3 em},\ystart);
\coordinate (2) at ({\xend-#3 em},\yend);
\ifdim\ystart=\yend
\draw[->] (\i.east)--(#2.west);
\else
\draw[->,rounded corners] (\i.east)--(1)--(2)--(#2.west);
\fi
}
\end{scope}
}
\begin{document}
\tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
}
}
\begin{tikzpicture}[]
\fontsize{8}{9} \selectfont
\matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
\node(n1){Text}; & \node(n3){another text}; \\
\node(n2){one thing}; & \node(n4){again text}; \\
};
\multilinks{n1,n2}{n3}{3}
\multilinks{n1}{n4}{1}
\end{tikzpicture}
\end{document}
を追加する必要があるので\ifdim
、Tiけrounded corners
Zは点からパスを描くように命令されると非常に混乱するあポイントへあ(つまり、2 つの同一点):
\documentclass[tikz,margin=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[y=0.2cm]
\draw[rounded corners] (0,0) --(1,0) --(1,0)--(2,0) ; % Some bugs?
\draw[rounded corners] (0,-1)--(1,-1)-- (2,-1);
\draw[rounded corners] (0,-2)-- (2,-2);
\end{tikzpicture}
\end{document}