\draw[->] で tikz を使用して丸い角をより適切に使用する

\draw[->] で tikz を使用して丸い角をより適切に使用する

次のようなコードがあります:

% !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、Tirounded cornersZは点からパスを描くように命令されると非常に混乱するポイントへ(つまり、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}

ここに画像の説明を入力してください

関連情報