2

As written in the title I need to let the lines go into the center of the circle. [Code Part at: %Pfeile von den Dots zu den K-Kreisen ] I don't want to use coordinates, only the nodes in reference to each other.

    \documentclass{standalone}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
    [thick,node distance = 12ex, 
    box/.style={fill=white,rectangle, draw=black}, 
    blackdot/.style={inner sep = 0, minimum size=3pt,shape=circle,fill,draw=black},
    plus/.style={fill=white,circle,inner sep = 0,thick,draw},
    metabox/.style={inner sep = 3ex,rectangle,draw,dotted,fill=gray!20!white}
    circle/.style={fill=white, circle, draw=black}
    ]

\node(Sum1) [box, minimum size = 6ex]{$\sum_{1}^{}$};
\node(Sum2) [box, minimum size = 6ex, below of = Sum1, yshift = 2 ex]{$\sum_{2}^{}$};

\node(k1) [plus, left of = Sum1, minimum size = 6 ex]{$k_1$};
\node(k2) [plus, right of = Sum2, minimum size = 6 ex]{$k_2$};

\node(dot1) [blackdot, right of = Sum1, xshift = -4ex]{};
\node(dot2) [blackdot, left of = Sum2, xshift = 4ex]{};

%Pfeile von den Dots zu den K-Kreisen
\node(Hilfspunkt2) [draw=none, fill=none, below of = dot2, yshift=4ex]{};
\draw [-] (dot2) -- (Hilfspunkt2){};
\draw [->] (Hilfspunkt2) -| (k2){};
\node(Hilfspunkt1) [minimum size = 0.1mm, above of = dot1, yshift=-4ex]{};
\draw [-] (dot1) -- (Hilfspunkt1){};
\draw [->] (Hilfspunkt1) -| (k1){};

%Pfeile zu den k-Kreisen
\node(out1)   [right of = k2, minimum size=0pt, inner sep = 0pt, xshift = -3ex]{};
\node(out2)   [left of = k1, minimum size=0pt, inner sep = 0pt, xshift = 3ex]{};
\draw[->](out1) -- (k2) node[below, xshift = 6 ex]{$v_2$};
\draw[->](out2) -- (k1)node[below, xshift = -6 ex]{$v_1$};

%Verbindung zwischen Sum-Boxen und den Nodepunkten
\draw[-](Sum1) -- (dot1){};
\draw[-](Sum2) -- (dot2){};

%Pfeile von den K-Kreisen zu den Sum-Boxen
\draw[->](k1) -- (Sum1)node[below, xshift=-6ex]{$u_1$};
\draw[->](k2) -- (Sum2)node[below, xshift=6ex]{$u_2$};

%Eckpfeile von den Nodepunkten zu den k-Kreisen
\draw[->] (dot1) -| (k2) node[xshift=-4ex, yshift=8ex]{$y_1$};
\draw[->] (dot2) -| (k1) node[xshift=4ex, yshift=-8ex]{$y_2$};

    \end{tikzpicture}
\end{document}
1
  • 2
    replace all \[ and ] with [ and ], than see what is your problem ...
    – Zarko
    Aug 7, 2018 at 13:21

2 Answers 2

3

You could use the center anchor of the nodes. And you could simplify your code, also by loading the positioning library.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
    \begin{tikzpicture}
    [thick,node distance = 12ex, 
    box/.style={fill=white,rectangle, draw=black}, 
    blackdot/.style={inner sep = 0, minimum size=3pt,shape=circle,fill,draw=black},
    plus/.style={fill=white,circle,inner sep = 0,thick,draw},
    metabox/.style={inner sep = 3ex,rectangle,draw,dotted,fill=gray!20!white}
    circle/.style={fill=white, circle, draw=black}
    ]

\node(Sum1) [box, minimum size = 6ex]{$\sum_{1}^{}$};
\node(Sum2) [box, minimum size = 6ex, below of = Sum1, yshift = 2 ex]{$\sum_{2}^{}$};

\node(k1) [plus, left of = Sum1, minimum size = 6 ex]{$k_1$};
\node(k2) [plus, right of = Sum2, minimum size = 6 ex]{$k_2$};

\node(dot1) [blackdot, right of = Sum1, xshift = -4ex,label=below:$y_1$]{};
\node(dot2) [blackdot, left of = Sum2, xshift = 4ex,label=above:$y_2$]{};

%Pfeile von den Dots zu den K-Kreisen
\node(Hilfspunkt2) [draw=none, fill=none,below=3em of dot2]{};
\draw [->] (dot2) -- (Hilfspunkt2.center) -| (k2);
\node(Hilfspunkt1) [minimum size = 0.1mm, above=3em of dot1]{};
\draw [->] (dot1) -- (Hilfspunkt1.center) -| (k1);

%Pfeile zu den k-Kreisen
\node(out1)   [right of = k2, minimum size=0pt, inner sep = 0pt, xshift = -3ex]{};
\node(out2)   [left of = k1, minimum size=0pt, inner sep = 0pt, xshift = 3ex]{};
\draw[->](out1) -- (k2) node[below, xshift = 6 ex]{$v_2$};
\draw[->](out2) -- (k1)node[below, xshift = -6 ex]{$v_1$};

%Verbindung zwischen Sum-Boxen und den Nodepunkten
\draw[-](Sum1) -- (dot1);
\draw[-](Sum2) -- (dot2);

%Pfeile von den K-Kreisen zu den Sum-Boxen
\draw[->](k1) -- (Sum1)node[midway,below]{$u_1$};
\draw[->](k2) -- (Sum2)node[midway,below]{$u_2$};

%Eckpfeile von den Nodepunkten zu den k-Kreisen
\draw[->] (dot1) -| (k2);
\draw[->] (dot2) -| (k1);

\end{tikzpicture}
\end{document}

Sadly imgur is rejecting my screenshots

6
  • Thank you this solved my problem (close to perfectly); Now the lines won't give a fine corner, they go for the two lines ending close to each other , giving three small corners in the corner. Do you know a solution to solve this? (About simplyfying the code, I'd be glad to hear a bit more but this is not for the comment section I supose) Imgur is also rejecting my screenshots.
    – Don Ky
    Aug 7, 2018 at 13:31
  • I just saw, you uploaded the simple version too. Thank you very much, this is pretty helpful to improve!
    – Don Ky
    Aug 7, 2018 at 13:33
  • @DonKy You are taking about \draw [->] (dot1) -- (Hilfspunkt1.center) -| (k1); and \draw [->] (dot2) -- (Hilfspunkt2.center) -| (k2);? There are no gaps in the output on my machine. Or are you talking about something else?
    – user121799
    Aug 7, 2018 at 13:34
  • 1
    The simplyfied way works out with no problem. The other option (my old one with redudant code) drawing one line and an arrow for the path led to this problem. Due to the fact I adapted the code with your improvements solves it with 100%.
    – Don Ky
    Aug 7, 2018 at 13:58
  • 1
    Me too, thank you! :) (I think it happened because the line went to the center as single, not connected paths, but their thickness gave a small stick out further then the center. So with your version, giving the path in one \draw command won't lead to this problem.
    – Don Ky
    Aug 7, 2018 at 14:05
0

for your image i would wrote code on the following way:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{positioning, quotes}

\begin{document}
    \begin{tikzpicture}[semithick,
          auto = right,
             > = Stealth,
 node distance = 6mm and 8mm,
    box/.style = {rectangle, draw, hick, minimum size=6ex},
    dot/.style = {circle, fill, minimum size=3pt,
                 inner sep = 0, outer sep=0pt,
                 node contents={}},
  circ/.style = {circle, draw, thick, minimum size=6ex, inner sep=0pt},
    ]
    % first line
\coordinate (in1);
\node (k1)      [plus,right=of in1]     {$k_1$};
\node (Sum1)    [box, right=of k1]      {$\sum_{1}^{}$};
\node(dot1)     [dot, right=of Sum1,label=below:$y_1$];
% second line
\node (Sum2)    [box, below=of Sum1]    {$\sum_{2}^{}$};
\node (k2)      [plus,right=of Sum2]     {$k_2$};
\node(dot2)     [dot, left =of Sum2, label=above:$y_2$];
\coordinate[right=of k2]  (in2);
% lines in the first line
\draw[->]   (in1)   edge["$v_1$"]    (k1)
            (k1)    edge["$u_1$"]   (Sum1)
            (Sum1) -|   (k2);
% loop on top
\draw[->]   (dot1) -- ++ (0,1) -| (k1);
% lines in the second line
\draw[->]   (in2)   edge["$v_2$" ']    (k2)
            (k2)    edge["$u_2$" ']   (Sum2)
            (Sum2) -|   (k1);
% loop on bottom
\draw[->]   (dot2) -- ++ (0,-1) -| (k2);
\end{tikzpicture}
\end{document}
  • code is shorter
  • for coordinates are used \coordinate (for both inputs)
  • "blackdots" are renamed to shorter "dot". since they are always empty, to style is added node content={}. beside this, is also set outer sep=0pt. by this is not necessary to draw lines from their center since they will touch dot
  • "plus" is renamed to "circ"
  • "circle" is deleted since:
    • it is not used,
    • it has name which is reserved name for shape "circle" (this can confuse tikz
  • for positioning is used syntax provided by the tikz library positioning. by this become all xshift and yshift superfluous and as such are removed from code

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .