Latex 如何用Tikz来阻止别人?
这是我试图用tikz制作的图表。块A、B和C位于块内(此处为红色背景的块),块E和F位于另一块内。两个巨大的块(红色背景)顶部有标签(LabA和LabB)。此外,我希望E块是正确的,在块A的中间,B.和箭头将阻止E应该有一些弯曲角度;所以,不像我试过的那个 这是我的密码Latex 如何用Tikz来阻止别人?,latex,tikz,Latex,Tikz,这是我试图用tikz制作的图表。块A、B和C位于块内(此处为红色背景的块),块E和F位于另一块内。两个巨大的块(红色背景)顶部有标签(LabA和LabB)。此外,我希望E块是正确的,在块A的中间,B.和箭头将阻止E应该有一些弯曲角度;所以,不像我试过的那个 这是我的密码 \documentclass[varwidth,border=7]{standalone} \usepackage{tikz} \usetikzlibrary{positioning,fit,calc} \tikzstyle{
\documentclass[varwidth,border=7]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,calc}
\tikzstyle{block} = [draw=black, thick, text width=2cm, minimum height=1cm, align=center]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}
\node[block] (a) {a};
\node[block, below=of a, yshift=0.7cm] (b) {b};
\node[block, below=of b, yshift=0.7cm] (c) {c};
\node[block, right=of c, xshift=0.7cm] (d) {d};
\node[block, right=of a, xshift=0.7cm, yshift=-0.4cm] (e) {e};
\draw [arrow] (a) -- (e);
\draw [arrow] (b) -- (e);
\draw [arrow] (c) -- (d);
\end{tikzpicture}
\end{document}
如何在某些节点上添加一个矩形,并在其上写一个标签。如何使箭头具有一定的倾斜角度(不直),并且在A和B块的中间和右侧有E块。我想我可以用
\draw[arrow](a)-(e)得到箭头代码>,但它不起作用。
先谢谢你
我尝试了一下,希望能得到正确的要求:
\documentclass[varwidth,border=7]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,calc}
\tikzstyle{block} = [draw=none, thick, text width=.4cm, minimum height=.5cm, align=center, fill=blue!50]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}
\Large
%red rectangles
\node (r1) [draw=none, fill=red, minimum width=1.2cm,minimum height=3.5cm]{};
\node (r2) [right=2cm of r1.center, anchor=center, draw=none, fill=red, minimum width=1.2cm,minimum height=3.5cm]{};
\node (r1Label)[above=0cm of r1] {\textbf{LabA}};
\node (r2Label)[above=0cm of r2]{\textbf{LabB}};
%nodes
\node[block, below=3mm of r1.north, anchor=north] (a) {\color{white}A};
\node[block, below=4mm of a] (b) {\color{white}B};
\node[block, below=4mm of b] (c) {\color{white}C};
\node[block, right=2cm of c.center, anchor=center] (d) {\color{white}D};
\node at ($(a.south)+(2,-.2)$) [block] (e) {\color{white}E};
%arrows
\draw [arrow, rounded corners=2] (a) -- ($(a)+(1,0)$) |- ($(e.west)+(0,.1)$);
\draw [arrow, rounded corners=2] (b) -- ($(b)+(1,0)$) |- ($(e.west)+(0,-.1)$);
\draw [arrow] (c) -- (d);
\end{tikzpicture}
\end{document}
因此:
一些解释:
- 通过在其他节点之前定义矩形,可以在后面绘制矩形。有更复杂的方法使用层,但我认为在这个例子中就足够了
- 我主要使用绝对距离,如给定的示例代码中所示。你可能需要调整。。。然而,使用这些,您可以很容易地找到A和B之间的中间位置(距离4mm),从而找到E的y位置(A.south+2mm)。使用($(node1)+(node2)$)可以计算节点位置
- 您提到的
-|-
选项分两步工作。首先将--
绘制到某个锚点(否则这是不明确的),然后将|--
绘制到目标节点
- “绘制”的“圆角”选项将圆角半径作为参数