1

I have a few questions regarding my MWE below.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\tikzstyle{cloud} = [ellipse, draw, fill=red!20, text centered, minimum width=50pt, minimum height=25pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20, text width=5em, text centered, rounded corners, minimum height=2em]
\tikzstyle{line} = [draw, -latex']

\begin{document}

\begin{tikzpicture}

\node[cloud] (mycloud) at (6.9,7) {Cloud};
\node[block]  (c1) at (5,5) {Consumer L1};
\node[block]  (c2) at (9,5) {Consumer L2};
\node[block]  (f1) at (6.9,3) {Feeder F1};

\path [line] (f1) - (mycloud); % fails
\path [line] (c1) |- (f1);
\path [line] (f1) -| (c2);
\path [line] (c1) |- (f1);

\end{tikzpicture}

\end{document}
  1. How do I draw a vertical arrow from the top ellipse (Cloud) to the bottom rectangle (Feeder F1)?
  2. Draw arrows from the center of the top edges of each of L1 and L2 to the center of the ellipse (i.e the bottom-most point of the ellipse)?
  3. Ensure that each of L1 and L2 is equidistant from the ellipse without manually specifying the co-ordinates?

Output

EDIT: I was able to solve 1) with \draw[->,-latex] (mycloud) -- (f1); but would like answers for 2) and 3)

After Edits

3
  • Please add with an external graphic program the arrows you want. – cis Oct 6 '20 at 23:08
  • @linuxfan please see if the answer below satisfies question 2 – js bibra Oct 7 '20 at 0:39
  • 1
    @linuxfan the positioning tikzlibrary helps with equal distancing without calculations as you can see in the edited answer below – js bibra Oct 7 '20 at 1:15
1

One more, "fancy" variation (for exercises), however with use of the recent syntax for defining styles of image elements:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
                positioning,
                shadows, shapes.symbols}

\begin{document}
    \begin{tikzpicture}[
 node distance = 4mm and 2mm,
mycloud/.style = {cloud, cloud puffs=9.4, aspect=2,
                  draw, draw, fill=red!20, drop shadow,
                  minimum width=50pt, align=center},
  block/.style = {draw, rounded corners, fill=blue!20, 
                  minimum height=2em, text width=5em, align=center},
    arr/.style = {semithick, -Stealth},
every edge/.style = {arr, draw}
                    ]
% nodes
\node[mycloud] (c0)  {Cloud};
\node[block, below  left=of c0] (c1) {Consumer L1};
\node[block, below right=of c0] (c2) {Consumer L1};
\node[block, below=of c0 |- c1.south] (f1) {Feeder F1};
% conections
\path   (c1) edge (c0)
        (c2) edge (c0)
        (c0) edge (f1);
\draw[arr]  (c1) |- (f1);
\draw[arr]  (f1) -| (c2);
    \end{tikzpicture}
\end{document}

enter image description here

1
  • Thanks @Zarko this solution is much nicer :) – linuxfan Oct 7 '20 at 15:45
1

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc}

\tikzstyle{cloud} = [ellipse, draw, fill=red!20, text centered, minimum width=50pt, 
minimum height=25pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20, text width=5em, text centered, 
 rounded corners, minimum height=2em]
\tikzstyle{line} = [draw, -latex']

\begin{document}

\begin{tikzpicture}

\node[cloud] (mycloud) at (6.9,7) {Cloud};
\node[block]  (c1) at (5,5) {Consumer L1};
\node[block]  (c2) at (9,5) {Consumer L2};
\node[block]  (f1) at (6.9,3) {Feeder F1};

%\path [line] (f1) - (mycloud); % fails
\path [line] (c1) |- (f1);
\path [line] (f1) -| (c2);
\path [line] (c1) |- (f1);

\draw[line]($(mycloud.south)+(0,-1em)$)-|(c2.north);
\draw[line]($(mycloud.south)+(0,-1em)$)-|(c1.north);
\draw[]($(mycloud.south)+(0,-1em)$)--(mycloud.south);
\end{tikzpicture}

\end{document}

EDIT up pointing arrows from L1 and L2

The positioning with the help of tiklibrary in preamble helps for equal distancing rather than manual calculation as desired in question 3

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc,positioning}

\tikzstyle{cloud} = [ellipse, draw, fill=red!20, text centered, minimum 
width=50pt, minimum height=25pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20, text width=5em, text 
centered, rounded corners, minimum height=2em]
\tikzstyle{line} = [draw, -latex']

\begin{document}

\begin{tikzpicture}

\node[cloud] (mycloud)  {Cloud};
\node[block, below left=of mycloud]  (c1) {Consumer L1};
\node[block, below right=of mycloud]  (c2) {Consumer L1};
\node[block, below=2cm of mycloud]  (f1)  {Feeder F1};

%\path [line] (f1) - (mycloud); % fails
\path [line] (c1) |- (f1);
\path [line] (f1) -| (c2);
\path [line] (c1) |- (f1);

\draw[line](c2.north)to(mycloud.south east);
\draw[line](c1.north)to(mycloud.south west);
\draw[line](mycloud.south)to(f1);
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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