如何不让线与同一点的节点相交

如何不让线与同一点的节点相交

我怎样才能将以下 MWE 中的两条线(水平)拉开,以使它们不会在同一点与节点相交?

% !TeX program = lualatex
\documentclass{standalone}

\usepackage{tikz}
    \usetikzlibrary{%
    positioning,%
    shapes}% 
    \tikzset{%
        Block/.style={rectangle, draw, text centered,text width=5em, rounded corners, minimum height=2em, inner sep=5pt},
        Linie/.style={draw},% line
    }

\begin{document}
    \begin{tikzpicture}
        % Nodes
        \node[Block] (Oben) {Oben};
        \node[Block, below left=of Oben] (Links) {Links};
        \node[Block, below right=of Oben] (Rechts) {Rechts};
        % Verbindungen
        \draw[Linie] (Oben) to[out=-90,in=90] (Links);
        \draw[Linie] (Oben) to[out=-90,in=90] (Rechts);
    \end{tikzpicture}
\end{document}

在此处输入图片描述 如果可能的话,这应该可以通过 MWE 中显示的两个以上的节点来实现。

答案1

像这样:

在此处输入图片描述

使用xshift=...来自“Oben”节点锚点south

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}%

\begin{document}
    \begin{tikzpicture}[
node distance = 7mm and 4mm,
   arr/.style = {-Stealth, rounded corners=2mm}, 
   box/.style = {draw, semithick, rounded corners, 
                 minimum height=2em,  text width=5em, align=center,
                 inner sep=5pt},
                        ]
% Nodes
\node[box] (Oben) {Oben};
\node[box, below  left=of Oben] (Links)  {Links};
\node[box, below right=of Oben] (Rechts) {Rechts};
% Verbindungen
\draw[arr] ([xshift=-2pt] Oben.south) -- ++ (0,-3mm) -| (Links);
\draw[arr] ([xshift=+2pt] Oben.south) -- ++ (0,-3mm) -| (Rechts);
    \end{tikzpicture}
\end{document}

注意:您pdfLaTeX也可以使用 来编译这个 MWE LuaLaTeX

答案2

通过一些手动换档:

% !TeX program = lualatex
\documentclass[margin=3pt]{standalone}

\usepackage{tikz}
    \usetikzlibrary{%
    positioning,%
    shapes}% 
    \tikzset{%
        Block/.style={rectangle, draw, text centered,text width=5em, rounded corners, minimum height=2em, inner sep=5pt},
        Linie/.style={draw},% line
    }

\begin{document}
    \begin{tikzpicture}
        % Nodes
        \node[Block] (Oben) {Oben};
        \node[Block, below left=of Oben] (Links) {Links};
        \node[Block, below right=of Oben] (Rechts) {Rechts};
        % Verbindungen
        \draw (Oben.south) 
             +(-1pt, 0pt) edge[out=-90,in=90] (Links)
             +( 1pt, 0pt) edge[out=-90,in=90] (Rechts);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

或者使用相对坐标:

% !TeX program = lualatex
\documentclass[margin=3pt]{standalone}

\usepackage{tikz}
    \usetikzlibrary{%
    calc,
    positioning,%
    shapes}% 
    \tikzset{%
        Block/.style={rectangle, draw, text centered,text width=5em, rounded corners, minimum height=2em, inner sep=5pt},
        Linie/.style={draw},% line
    }

\begin{document}
    \begin{tikzpicture}
        % Nodes
        \node[Block] (Oben) {Oben};
        \node[Block, below left=of Oben] (Links) {Links};
        \node[Block, below right=of Oben] (Rechts) {Rechts};
        % Verbindungen
        \draw[out=-90,in=90]
          ($ (Oben.south west)!.48!(Oben.south east) $) edge (Links)
          ($ (Oben.south west)!.52!(Oben.south east) $) edge (Rechts);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容