我正在做一个项目,我正在尝试用tikzpicture
(请忽略中间的希腊字母和周围的方框):
我已经设法近似这张图片中的tikzpicture
代码如下:
tikzstyle:
\tikzstyle{block} = [draw, fill=white!20, rectangle,
minimum height=1.5em, minimum width=1.5*1.86em]
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
tikz图片:
\begin{tikzpicture}[auto, node distance=1.5cm, >=latex']
\node [input, name=input]{$r=0$};
\node [sum, right of=input](sum1){};
\node [coordinate, right of=sum1](test2){};
\node [block, right of=test2](a){a};
\node [sum, right of=a](sum2){};
\node [block, right of=sum2](dint){$\frac{1}{s^2}$};
\node [block, below of=a](b){b};
\node [coordinate, below of=b](test){};
\node [output, right of=dint](output){qq};
\draw [->] (input) -- node{$r$} node[pos=0.99]{$+$} (sum1);
\draw [->] (sum1) -- node{} (a);
\draw [->] (a) -- node[pos=0.99]{$+$} (sum2);
\draw [->] (test2) |- (b) -| node[pos=0.99]{$+$}(sum2);
\draw [->] (sum2) -- node{} (dint);
\draw [->] (dint) -- node[name=y]{$y$} (output);
\draw [->] (y) |- (test) -| node[pos=0.99] {$-$} (sum1);
\end{tikzpicture}
其结果如下:
但是,我没有找到插入开关符号的方法。是否有预定义的符号tikzpicture
(尽管我找不到)?如果没有,是否可以用其他方式解决问题?
答案1
这是一个可行的方法:
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{circuits.ee.IEC}
\begin{document}
\begin{tikzpicture}[circuit ee IEC, font=\sffamily\footnotesize]
\draw (0,0) to [make contact={info={S$\mathsf{_{1a}}$},info'={make contact$\mathsf{_{}}$}}] (2,0);
\draw (3,0) to [break contact={info={S$\mathsf{_{1a}}$}, info'={break contact$\mathsf{_{}}$}}] (5,0);
\draw[set make contact graphic = var make contact IEC graphic] (0,-2) to [make contact={info ={S$\mathsf{_{1a}}$}, info'={var make contact}}] (2,-2);
\end{tikzpicture}
\end{document}
这是取自德国网站Matroids Matheplanet
。输出如下:
希望能帮助到你!
答案2
我终于设法使用一个名为的附加包解决了这个问题circuitikz
,所以我将它的一个元素组合到我现有的 tikzpicture 图像中:
附加包:
\usepackage{circuitikz}
tikzstyle(小修改):
\tikzstyle{block} = [draw, fill=red!20, rectangle,
minimum height=1.5em, minimum width=1.5*1.80em]
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
tikzpicture(请原谅元素的名称):
\begin{tikzpicture}[auto, node distance=2cm, >=latex']
\node [input, name=input]{$r=0$};
\node [sum, right of=input](sum1){};
\node [coordinate, right of=sum1](test2){};
\node [block, right of=test2](a){a};
\node [coordinate, right of=a](test4){};
\node [sum, right of=test4](sum2){};
\node [block, right of=sum2](dint){\large $\frac{1}{s^2}$};
\node [block, below of=a](b){b};
\node [coordinate, right of=b](test5){};
\node [coordinate, below of=sum2](test3){};
\node [coordinate, below of=b](test){};
\node [coordinate, right of=a](test4){};
\node [output, right of=dint](output){qq};
\draw [->] (input) -- node{$r$} node[pos=0.99]{$+$} (sum1);
\draw [->] (sum1) -- node{} (a);
\draw [->] (a) -- node[pos=0.99]{$+$} (sum2);
\draw [->] (test2) |- (b);
\draw [-] (b) -- (test5);
\draw [-] (test5) to[cspst] (test3);
\draw [->] (test3) -- node[pos=0.9]{$+$} (sum2);
\draw [->] (sum2) -- node{} (dint);
\draw [->] (dint) -- node[name=y]{$y$} (output);
\draw [->] (y) |- (test) -| node[pos=0.99] {$-$} (sum1);
\end{tikzpicture}
该工作通过以下命令完成:
\draw [-] (test5) to[cspst] (test3);
我定义了两个coordinate
元素:
test5
位于开关左侧。test3
位于开关的右侧。
通过to[cpspst]
在这两个不可见元素之间绘制一个开关,因此其余任务可以通过问题已经使用的命令轻松完成tikzpicture
。这将产生以下图像: