Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I ma using tikz to draw a flowchart.Some of the arrows connecting the decision diamonds to the blocks are shorter than other arrows and I do not know how to make all of the arrows with same length. here is the code:

\begin{tikzpicture}[node distance = 2cm, auto][t]
\node [block] (init) {Perform load forecast} ++(-3.4,+.1);
\node [block, below of=init] (evaluate) {Execute optimization};
\node [block, below of=evaluate] (SOC) {Read SOC of BESS from SCADA};
\node [block, right of=SOC, node distance=3cm] (constraint) {Modify optimization constraint};
\node [decision, below of=SOC] (decide) {Is next BESS active power command violate
 SOC constraint?};
\node [block, below of=decide, node distance=3.5cm] (stop) {Send BESS active power command};
\node [block, below of=decide, node distance=3.5cm] (active) {Send BESS active power command};
\node [block, below of=active, node distance=2cm] (rscada) {Read reactive power load from SCADA};

\node [decision, below of=rscada,node distance=2.6cm] (decide1) {$Q_{res}>Q_L$?};

 \node [block, below of=decide1, node distance=2.6cm] (injq) {Inject $Q_l$};

\node [block, right of=injq, node distance=3cm] (qres) {Inject $Q_{res}$};

% Draw edges
\path [line] (init) -- (evaluate);
\path [line] (evaluate) -- (SOC);
\path [line] (SOC) -- (decide);
\path [line] (decide) -- node[near start] {N}(active);
\path [line] (decide) -| node [very near start]{Y}(constraint);
\path [line] (active) -- (rscada);
\path [line] (rscada) -- (decide1);
\path [line] (decide1) --  node [near start] {Y}(injq);
\path [line] (decide1) -| node [very near start] {N}(qres);

 \path [line] (constraint) |- (evaluate);

\path [line] (qres.east) -- ++(.53,0) node(lowerright){} |- (init.east);
\draw (0,-18.9) -- (0,-19.5);
\draw (3,-18.9) -- (3,-19.5);
\draw (0,-18.9) -- (0,-19.5);
\draw (0,-19.5) -- (4.71,-19.5);
\draw (4.71,-19.5) -- (4.71,-18.1);
\end{tikzpicture}

flowchart

share|improve this question
    
Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Christian Hupfer Aug 7 at 22:12
    
Sorry but I don't really understand the question. In your code, you specify various different distances between nodes. Then you draw arrows between the nodes. So the length of the arrows varies because the distances vary. If you want them all the same, specify the same distances. What am I missing? Maybe you want to use specify anchors to get the distances the same e.g. below=5mm of so-and-so.south or whatever? (Use the positioning library.) –  cfr Aug 7 at 23:30

1 Answer 1

I'm guessing your missing styles because you didn't provide a full MWE. But you can drop usage of below of,right of keys as they are deprecated. See

So you can provide below = 2cm of <node name> syntax instead of node distance tweaks all the time. In your case increase the amount in the decide node declaration something like below = 3cm of SOC or something like that.

% in the preamble
\usetikzlibrary{positioning,shapes.geometric}
%...........
%...........
%...........
\begin{tikzpicture}[>=latex,auto,block/.style={align=center,draw,text width=2cm},decision/.style={diamond,draw,text width=2cm,align=center},line/.style={draw,->}]
\node [block] (init) {Perform load forecast} ++(-3.4,+.1);
\node [block, below = of init] (evaluate) {Execute optimization};
\node [block, below = of evaluate] (SOC) {Read SOC of BESS from SCADA};
\node [block, right = of SOC] (constraint) {Modify optimization constraint};
\node [decision, below = of SOC] (decide) {Is next BESS active power command violate
 SOC constraint?};
\node [block, below = of decide] (stop) {Send BESS active power command};
\node [block, below = of decide] (active) {Send BESS active power command};
\node [block, below = of active] (rscada) {Read reactive power load from SCADA};

\node [decision, below = of rscada] (decide1) {$Q_{res}>Q_L$?};
\node [block, below = of decide1] (injq) {Inject $Q_l$};
\node [block, right = of injq] (qres) {Inject $Q_{res}$};
% Draw edges
\path [line] (init) -- (evaluate);
\path [line] (evaluate) -- (SOC);
\path [line] (SOC) -- (decide);
\path [line] (decide) -- node[near start] {N}(active);
\path [line] (decide) -| node [very near start]{Y}(constraint);
\path [line] (active) -- (rscada);
\path [line] (rscada) -- (decide1);
\path [line] (decide1) --  node [near start] {Y}(injq);
\path [line] (decide1) -| node [very near start] {N}(qres);
\path [line] (constraint) |- (evaluate);
\path [line] (qres.east) -- ++(.53,0) node(lowerright){} |- (init.east);
\end{tikzpicture}

enter image description here

share|improve this answer
    
Thanks percusse. how can i connect the injq block from bottom to init on the top? I'd like a line coming down, then right and then connects the existing line going out of qres. –  Ehsan Aug 8 at 1:37
    
I guess it should be like this:\path [line] (qres.south) |- ++(1.53,-.5) node(lowerright){} |- (init.east); \path [line] (injq.south) |- ++(4.78,-.5) node(lowerright){} |- (init.east); –  Ehsan Aug 8 at 2:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.