1

Ok, I have another question. I can make a loop diagram with the matrix way:

Loop diagram

However working with nodes seems way more convenient, this is my code:

\documentclass[12pt, letterpaper, twoside]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}

\begin{document} \tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30] \tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30] \tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30] \tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30] \tikzstyle{arrow} = [thick,->,>=stealth] \begin{tikzpicture}[node distance=2cm] \node (start) [startstop] {Start}; \node (in1) [io, below of=start] {Input}; \node (pro1) [process, below of=in1] {Loop start}; \node (pro2) [process, below of=pro1] {Process 1}; \node (pro3) [process, below of=pro2] {Process 1}; \node (dec1) [decision, below of=pro3, yshift=-0.5cm] {Decision 1};

\draw [arrow] (start) -- (in1);
\draw [arrow] (in1) -- (pro1);
\draw [arrow] (pro1) -- (pro2);
\draw [arrow] (pro2) -- (pro3);
\draw [arrow] (pro3) -- (dec1);

\end{tikzpicture} \end{document}

I tried to apply the same technique that I used with the matrices but there were cryptic errors about an undefined control sequence...

So, what is the best way to add a rectangular connector with a little no (or yes) on it?

Zarko
  • 296,517
Qni
  • 87
  • Yor MWE works without any warnings or errors. However, it not reproduce showed image. If this is following-up question, please provide a link to this question. And what is the problem? To draw feedback line? Placement of labels "No" and "Yea"? BTW, use of \tikzstyle is deprecated ... – Zarko Jan 10 '21 at 09:13
  • I guess, that you looking for something similar to this flowchart: http://tex.stackexchange.com/questions/300759/write-easily-a-tikz-flowchart/300829#300829 – Zarko Jan 10 '21 at 09:38
  • Yea, I tried adding the line
    \draw [arrow] (dec1) |- ($(dec1.south east)!0.5!(pro1.north east)$) -| ([xshift=7mm] pro1)
    

    but it creates a very strange path...

    Thanks for the headsup about tikzstyle. This is a self contained problem, sorry it isn't clear, not sure how to clarify... I want the code to produce a picture like the one shown

    – Qni Jan 10 '21 at 09:52
  • \draw [arrow] (dec1) -- (dec1.east) -- (pro1.east) -- (pro1); almost works, but I need the line to go out a little further... – Qni Jan 10 '21 at 10:04

2 Answers2

3

Sorry, your question is not clear. Your MWE is not close to showed image, description of your problem problem is unclear. So, see if the following MWE, based on guessing and on my answer to the similar question, gives what you after:

\documentclass[border=3mm, tikz]{standalone}
\usetikzlibrary{arrows.meta,
                chains,
                positioning,
                quotes,
                shapes.geometric}

\begin{document} %---------------------------------------------------------------% % based on: % http://tex.stackexchange.com/questions/300759/write-easily-a-tikz-flowchart/300829#300829 %---------------------------------------------------------------% \begin{tikzpicture}[ node distance = 6mm and 18mm, start chain = A going below, % arr/.style = {-Straight Barb, semithick}, base/.style = {draw, minimum width=32mm, minimum height=8mm, align=center, on chain=A, join=by arr}, startstop/.style = {base, rounded corners, fill=red!30}, % <--- process/.style = {base, fill=orange!30}, % <--- io/.style = {base, trapezium, trapezium stretches body, trapezium left angle=70, trapezium right angle=110, fill=blue!30}, decision/.style = {base, diamond, fill=green!30}, every edge quotes/.style = {auto=right, font=\small} ] \node [startstop] {input}; % <-- A-1 \node [process] {Loop start}; \node [process] {1}; \node [process] {2}; \node [decision] {Yes or No ?}; \node [startstop] {Stop}; % <-- A-6 %% \draw[arr] (A-5.west) to ["No"] ++ (-1.8,0) |- (A-2); % feedback loop \path (A-5) to ["Yes"] (A-6); \end{tikzpicture} \end{document}

enter image description here

Zarko
  • 296,517
0

Alright, added [xshift=7mm] and now it works:

    \draw [arrow] (dec1) -- node[anchor=north] {Yes} ([xshift=7mm] dec1.east) -- ([xshift=7mm] pro1.east) -- (pro1);

enter image description here

Is this the best way though?

Qni
  • 87
  • Is this an answer to your question? Or you just like to clarify, your problem? – Zarko Jan 10 '21 at 10:16
  • It is an answer – Qni Jan 10 '21 at 10:20
  • No, in the last sentences you have a question. Short answer on it is: NO. – Zarko Jan 10 '21 at 10:23
  • It is a complete answer to the question... If it is the theoretical best answer is a philosophical question that could be posed to any answer – Qni Jan 10 '21 at 11:55
  • It is not complete answer. Anyone, who like to test it, if it really solve your problem, need to compose own MWE for this. MWE in your question use deprecated syntax, it is not exactly useful for this. – Zarko Jan 10 '21 at 13:40
  • It solves my use case atleast – Qni Jan 10 '21 at 13:46