如果有人能帮我画出所附的图表我将非常高兴。
这是我编写的代码:
\tikzstyle{block} = [draw, fill=cyan, regular polygon,
minimum height=3em, minimum width=6em]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
\begin{figure}[ht]
\centering
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
\node [input, name=input] {};
\node [block, right of=sum] (Ablock) {A} edge [loop above] node {$\alpha$} (A);
\node [block, right of=Ablock, node distance=4cm] (Bblock) {B} edge [loop above] node {$\beta$} (A);
\draw [->] (Ablock) -- node[name=b] {a} (Bblock);
\begin{scope}[transform canvas={yshift=-2mm}]
\draw [->] (Bblock) -- node[name=a] {$b$} (Ablock);
\end{scope}
\node [output, right of=Bblock] (output) {};
\node [block, below of=b] (Cblock) {C} edge [loop below] node {$\gamma$} (C);
\draw [->] (sum) -- node {} (Ablock);
\draw [-] (Bblock) -| (output) node [name=c] {};
\draw [-] (c) |- (Cblock);
\draw [-] (Cblock) -| [near end] {} (sum);
\end{tikzpicture}
\end{figure}
答案1
库:
arrows.meta
获取最新的箭头提示(以大写字母开头)。positioning
为了right = of …
代替right of = …
。ext.paths.ortho
用于路径操作r-rl
和快捷方式|-
和-|
。cd
为shift left
关键(较之有优点和缺点transform canvas
)。
代码
\documentclass[tikz, border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{
arrows.meta, % for newest arrow tips (capital letters)
positioning, % for better placement via left=of …
shapes.geometric, % for regular polygon
quotes, % for "…" syntax
ext.paths.ortho, % for r-rl and |-/-| shortcuts
cd} % for shift left
\tikzset{
cd/.code=\pgfqkeys{/tikz/commutative diagrams}{#1}%
}
\begin{document}
\begin{tikzpicture}[
>=Latex,
arr/.style={->, every edge quotes/.append style={
execute at begin node=$, execute at end node=$},
every loop/.append style={looseness=5}},
dot/.style={circle, fill, draw, inner sep=+.7pt},
block/.style={draw, fill=cyan, regular polygon, minimum size=6em},
]
\node[block] (C) {C};
\node[above=of C, dot] (c-above) {};
\node[above left =of c-above, block] (A) {A};
\node[above right=of c-above, block] (B) {B};
\coordinate[left=of A] (a-left);
\node[dot] (c-left) at (C-|a-left) {};
\path[arr, ortho/install shortcuts]
(c-above) edge["c"'] (C)
(A) edge[|-] (c-above)
(B) edge[|-] (c-above)
(C) edge["d"] (c-left)
(c-left) edge[|-] (A)
(A) edge[loop above, "\alpha"] () % loops don't need a target
(B) edge[loop above, "\beta"] ()
(C) edge[loop below, "\gamma" name=gamma] () % name this node
(B) edge[to path={ % so we can use it here
r-rl ([yshift=-5mm]gamma.south)
\tikztonodes % if you need nodes along the path
-|(\tikztotarget)
}] (c-left)
(A) edge["a"] (B)
[cd={shift left=2mm}]
(B) edge["b"] (A)
;
\end{tikzpicture}
\end{document}
输出
答案2
我对你的代码进行了一些编辑,得到了这个结果!
\documentclass[tikz, border=20mm]{standalone}
\usetikzlibrary {shapes.geometric}
\tikzstyle{block} = [draw, fill=cyan, regular polygon,
minimum height=3em, minimum width=6em]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
\begin{document}
\begin{tikzpicture}[auto, node distance=2cm,>=stealth]
\node [input, name=input] {};
\node [block] (Ablock) {A} edge [loop above] node {$\alpha$} (A);
\node [block, right of=Ablock, node distance=4cm] (Bblock) {B} edge [loop above] node {$\beta$} (A);
\draw [->] (Ablock) -- node[name=b] {a} (Bblock);
\begin{scope}[transform canvas={yshift=-2mm}]
\draw [->] (Bblock) -- node[name=a] {$b$} (Ablock);
\end{scope}
\node [output, right of=Bblock] (output) {};
\node [block, right=2cm, below=4cm] (Cblock) {C} edge [loop below] node {$\gamma$} (C);
\draw[->] (Cblock)--++(-3.75,0)node[midway, below] {$d$} node[left=0.1cm] (ac) {};
\draw[->] (ac)|-(Ablock);
\draw[->] (Ablock.south)--++(0,-1)--++(1.75,0);
\draw[->] (Bblock.south)--++(0,-1)--++(-1.75,0) node[left=0.1cm] (c) {};
\fill[cyan] (c)circle(0.05);
\fill[cyan] (ac)circle(0.05);
\draw[->] (c)--(Cblock.north) node[left, midway] {$c$};
\draw[->] (Bblock)--++(2,0)--++(0,-8)--++(-8,0)--(ac);
\end{tikzpicture}
\end{document}
看来,当在另一个文档类中执行此代码时,它不会产生预期的结果。要解决此问题,您有两个选择。首先,您可以适当调整坐标,因为一切都是成比例的。或者,您可以重新编译此处描述的所有内容,并使用包将其包含在您的文件中graphicx
(例如\includegraphics[scale=0.75]{diagram.pdf}
:)。这也应该有效。
但是,我强烈建议您花时间了解@Qrrbrbirlbel 的答案,因为它条理清晰,涉及从头开始重新定义所有内容。在我的回答中,我只编辑了您的代码以获得所需的图表。