# How to draw integrator block with Tikz?

Is it possible to draw this shape in Tikz?

It is an integrator block in a block diagram.

• Yes, it is possible.
– user31034
Oct 12 '14 at 10:09
• @ferahfeza Funny :) I've managed to make it look like this. The problem is I have to combine multiple shapes which require multiple lines of code. I'm looking for a way of writing \node [integrator, right of=input] (integrator) {}; Oct 12 '14 at 10:14
• you may find the \pic macro interesting (pag. 252 of the manual) Oct 12 '14 at 10:16
• @FriendofKim It would be good if you stated that in the question itself as well, so people don't have to look through the comments to find out what the real problem is. You can edit your post to do that. Also, sort of related question: tex.stackexchange.com/questions/18400/… Oct 12 '14 at 12:28
• @TorbjørnT. The reason why I didn't state it was the XY problem. Oct 12 '14 at 14:20

You can use the /.pic construct to do this. You draw the elements you want (Integrator, differentiator, etc.) in a picture environment and just insert these pictures wherever you want just like a node. Here is an attempt (meaningless blocks just to show the method):

\documentclass[border=1mm,tikz]{standalone}
\usetikzlibrary{calc,positioning}
\begin{document}

\tikzset{integ/.pic={
\draw [blue,fill=green!30](0,2.5)rectangle(1,-2.5) (1,2.5)--(6,0)--(1,-2.5)--cycle node at (1.5,0) {$\displaystyle \int$};
}, dif/.pic={
\node at (0,0) [blue, fill=green!30, draw,rectangle, minimum size=1.2cm] {$\displaystyle \frac{d}{dt}$};}}

\begin{tikzpicture}[nd/.style={draw, circle,inner sep=0pt,minimum size=4pt}]
\path (0,0) node (in) [nd,label={left:Input}]{} node (out) [nd,label={right:Output},right=6.5cm of in]{};
\path [draw] (in)--(out)  (in) pic [right=of in, scale=0.3]{integ} (in) pic [right=4cm of in, scale=1]{dif} node(ff){};
\end{tikzpicture}

\end{document}


which gives the following output:

For the system as per the OP comment we can do this:

\documentclass[border=.2mm,tikz]{standalone}
\usetikzlibrary{calc,positioning}
\begin{document}

\tikzset{integ/.pic={
\draw [fill=blue!10](0,2.5)rectangle(1,-2.5) (1,2.5)--(6,0)--(1,-2.5)--cycle node at (1.5,0) {};}}
\small
\begin{tikzpicture}[>=stealth,nd/.style={draw,fill=blue!10,circle,inner sep=0pt,minimum size=5pt}, blk/.style={draw,fill=blue!10,minimum height=0.8cm,text width=1.5cm, text centered}]
\path (0,0)coordinate(in) node(dif)[nd,right=.7cm of in,label=below left:$-$]{} node(Reg)[blk,right=of dif]{Regulator} coordinate[below right=of Reg](intg) node(sys)[blk,right=of Reg]{System} node(Dis)[above=.5cm of sys]{Disturbances} node(out)[right=of sys]{} node(y)at($(sys)!.65!(out)$)[above]{$y$};
\draw[->] (in)--node[above]{$r$}(dif);
\draw[->](dif)--node[above]{$e$}(Reg);
\draw[->](Reg)--node[above]{$u$}(sys);
\draw[->](sys)--(out);
\draw[->](Dis)--(sys);
\draw[->] (y)|- (intg);
\draw[->] (intg)-| node[above left,yshift=.5cm]{$y_m$}(dif);
\path (intg) pic[scale=0.17,rotate=180,outer sep =0pt] {integ};
\end{tikzpicture}
\end{document}


Now with the following output:

• Thank you for an excellent answer! Is it possible to give a \pic a name? I'm trying this code, but it does not work. pastebin.com/MymrJxrg Oct 12 '14 at 19:34
• It is supposed to look like this, only with the integrator block instead of the text: oi59.tinypic.com/65bghh.jpg Oct 12 '14 at 19:36
• @FriendofKim See my updated answer. Oct 12 '14 at 22:13