# Drawing a closed loop diagram with Tikz with multiple inputs

I am using Tikz for the first time and I am having trouble coming up with a diagram I am required to draw

The diagram is this I have found a code and attempted to modify it to make it resemble as much as the top diagram as possible (down to thickness of the lines), but whenever I do something it seems to create an error message. I can't even move the plus sign to the right of the line.

I am not aware of the capability of Tikz, if this diagram is not possible using Tikz please let me know and I will use my current non-Tikz method to draw which takes me about 30 seconds. Unfortunately it does not have the flexibility to be changed on the fly (and more importantly the Latex font I need for the diagram). \tikzstyle{block} = [draw, fill=white, rectangle,
minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=white, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]

\begin{figure}[ht]
\centering
\begin{tikzpicture}[auto, node distance=2cm,>=latex']

\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (Ablock) {A};
\node [block, right of=Ablock, node distance=4cm] (Bblock) {B};

\draw [->] (Ablock) -- node[name=b] {$b_1$} (Bblock);
\node [output, right of=Bblock] (output) {};
\node [block, below of=b] (Cblock) {C};

\draw [->] (sum) -- node {$a_1$} (Ablock);

\draw [->] (Bblock) -- node [name=c] {$c_1$}(output);
\draw [->] (c) |- (Cblock);
\draw [->] (Cblock) -| node[pos=0.99] {$+$}
node [near end] {} (sum);
\end{tikzpicture}
\end{figure}


I would appreciate if anyone could help me with creating the above diagram.

• there is no input in the first additioner? a+ what ? – SAM Jul 10 '16 at 9:37
• @SAM Yes, because there is no input from outside, just feedback – Carlos - the Mongoose - Danger Jul 10 '16 at 9:39
• there is no need to an additionner in this case just put the entry a in the bloc A. – SAM Jul 10 '16 at 9:42
• "a diagram I am required to draw" --- is this homework? Can I come and join the class?! – Thruston Jul 10 '16 at 18:36

## 1 Answer

See, if the following solution is acceptable to you:

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

\makeatletter
\def\tikzsavelastnodename#1{\let#1=\tikz@last@fig@name}
\makeatother
\newcommand\ppbb{path picture bounding box}

\tikzset{%
node distance=9mm and 12mm,
shorten <>/.style = {%
shorten >=#1, shorten <=#1
},
dot/.style={%
circle, fill=black,
minimum size=1mm, inner sep=0mm, outer sep=0mm,
node contents={}
},
sum/.style={%
circle, draw=black, minimum size=6mm,
path picture={\draw[very thick,shorten <>=1mm,-]
(\ppbb.north) edge (\ppbb.south)
(\ppbb.west)   --  (\ppbb.east);
},% end of node contents
node contents={}},
element/.style={%
draw, thick,
minimum size=11mm, inner xsep=5mm,
append after command={\pgfextra{\tikzsavelastnodename\tikzsavednodename}},#1
},
subelement/.style args={#1:#2}{%
append after command =
{node[minimum size=3mm,
font=\footnotesize,% <-- new
inner sep=2pt] at (\tikzsavednodename.#1) [anchor=#1] {#2}}
},
every path/.style = {->, semithick} % <-- new
}% end of tikzset

\begin{document}
\begin{tikzpicture}
% first row
\node (n1) [sum];
\node (n2) [element,
subelement=north east:$\alpha$,
right=of n1]    {$A$};
\node (n3) [element,
subelement=north east:$\beta$,
right=of n2]    {$B$};
\node (n4) [dot,
right=of n3];
% second row
\node (n5) [element,
subelement=north east:$\omega$,
below=of n2]    {$D$};
\node (n6) [element,
subelement=north east:$\gamma$,
below=of n3]    {$C$};
% lines
\draw (n1) to ["$a$"] (n2);
\draw (n2) to ["$b_1$"] (n3);
\draw (n3) to ["$c_1$"] (n4) -- + (0.7,0);
\draw (n4) |- (n6);
\draw (n6) to ["$d_1$" '] (n5);
\draw (n5) -| (n1.south) node[below right] {$+$};
%lines with transformed canvas
\begin{scope}[transform canvas={yshift=-3mm}]
\draw ($(n2)!0.6!(n3)$) node[left] {$b_2$} -- (n3);
\draw ($(n5)!0.4!(n6)$) node[right] {$d_2$} -- (n5);
\draw (n4 |- n6) node[right] {$c$} -- (n6);
\end{scope}
\end{tikzpicture}
\end{document} Note: Above MWE is rather complex and sophisticated, however it is also modular with predefined styles collected in common \tikzset. By this a uniform image looks and relatively simple image design is achieved.

Predefined styles are:

• sum for summation node in picture. Plus inside can simply be customized by changing of thickness (set is to very thick) of inner lines and their lengths (determined with shorten <>=1mm). For drawing lines for sign plus a path picture bounding boxis used, in shorter writing it is defined with a new command ppbb.
• dot is intended for marking lines connection points.
• element is style for main nodes in diagram. In it is by append after command prepared possibility to write labels inside it
• subelement is named a label, which is positioned inside anelement node. It is used to write Greek letters in above right corners of element node.

Connection lines between nodes are labeled with help of TikZ library quotes. Additional inputs to some of nodes are drawn in scope which with transform canvas moves them to right position.

Addendum: Presence of the node sum in the scheme is not very logical. Inmy opinion it is surplus and should be replaced with simple coordinate. MWE (without preamble, which is the same as above) in this case it is:

    \begin{tikzpicture}
% first row
\coordinate (n1) at (0,0);
\node (n2) [element,
subelement=north east:$\alpha$,
right=of n1]    {$A$};
\node (n3) [element,
subelement=north east:$\beta$,
right=of n2]    {$B$};
\node (n4) [dot,
right=of n3];
% second row
\node (n5) [element,
subelement=north east:$\omega$,
below=of n2]    {$D$};
\node (n6) [element,
subelement=north east:$\gamma$,
below=of n3]    {$C$};
% lines
\draw (n2) to ["$b_1$"] (n3);
\draw (n3) to ["$c_1$"] (n4) -- + (0.7,0);
\draw (n4) |- (n6);
\draw (n6) to ["$d_1$" '] (n5);
\draw (n5) -| (n1) to ["$a$"] (n2);
%lines with transformed canvas
\begin{scope}[transform canvas={yshift=-3mm}]
\draw ($(n2)!0.6!(n3)$) node[left] {$b_2$} -- (n3);
\draw ($(n5)!0.4!(n6)$) node[right] {$d_2$} -- (n5);
\draw (n4 |- n6) node[right] {$c$} -- (n6);
\end{scope}
\end{tikzpicture}


and picture is: Edit: Now is considered wish expressed in your comment. For lines is added to \tikzset is added style for every path where is defined that lines are slightly thicker and each have arrow on the right side. Also are defined smaller font size in subelement and improved appearance of dot . This changes are considered onbly in second image (without sum).

• Thanks, this is great. I think I can live without the huge + sign in the circle. Do you know if there is a way to make the width of the lines a bit thicker ? – Carlos - the Mongoose - Danger Jul 10 '16 at 9:45
• yes, thickness of lines is easy to change (for example with ad option thick or very thick etc). I will (after lunch) add short explanation to this rather complex solution in which I will consider your comment too. – Zarko Jul 10 '16 at 9:57
{"ft_lang_label":"__label__en","ft_lang_prob":0.7103088,"math_prob":0.9748947,"size":4409,"snap":"2019-35-2019-39","text_gpt3_token_len":1482,"char_repetition_ratio":0.123269014,"word_repetition_ratio":0.27597404,"special_character_ratio":0.33613065,"punctuation_ratio":0.1732852,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9984362,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,3,null,3,null,3,null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-08-22T00:09:00Z\",\"WARC-Record-ID\":\"<urn:uuid:a2e17021-0bc5-43f4-a2b3-f8ce7deb052e>\",\"Content-Length\":\"147488\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:26bdcc16-c1d0-4c49-868d-d0638a8e5efe>\",\"WARC-Concurrent-To\":\"<urn:uuid:85aca383-6587-4427-b403-594b4c65e32f>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://tex.stackexchange.com/questions/318762/drawing-a-closed-loop-diagram-with-tikz-with-multiple-inputs\",\"WARC-Payload-Digest\":\"sha1:UHSYAO4CDWLBTH3NJYZSUNBX2AXARLAQ\",\"WARC-Block-Digest\":\"sha1:DRA2CFILJFKC65HPVL23VPKCCWEZDB6L\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-35/CC-MAIN-2019-35_segments_1566027316555.4_warc_CC-MAIN-20190822000659-20190822022659-00330.warc.gz\"}"}