在 tikz 中绘制垂直和倾斜箭头

在 tikz 中绘制垂直和倾斜箭头

我对我的 MWE 有以下几个问题。

\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. 如何从顶部椭圆(云)到底部矩形(Feeder F1)绘制垂直箭头?
  2. 从每个顶部边缘的中心画出箭头L1L2到椭圆的中心(即椭圆的最底点)?
  3. 确保每一个L1L2是否与椭圆等距,无需手动指定坐标?

输出

编辑:我能够解决1)\draw[->,-latex] (mycloud) -- (f1);想要得到答案2)3)

编辑后

答案1

还有一个“花哨”的变体(用于练习),但是使用了最新的语法来定义图像元素的样式:

\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}

在此处输入图片描述

答案2

在此处输入图片描述

\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}

编辑从 L1 和 L2 向上指向的箭头

在序言中,借助positioningtiklibrary 可以帮助实现相等距离,而不是像问题 3 中那样进行手动计算

在此处输入图片描述

\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}

相关内容