# Defining a new node shape for an electronic multiplexer

I found this question which suggests making a multiplexer symbol with this path:

(0,0) -- (1,-0.5) -- (1,-1.25) -- (1.3,-1.25) -- (1,-1.25)-- (1,-2) -- (0,-2.5) --
(0,-1.75) -- (-0.3,-1.75) -- (0,-1.75) -- (0,-0.75) -- (-0.3,-0.75) -- (0,-0.75) --
(0,0)


The answer suggests doing this to use it as a symbol:

\documentclass{article}
\usepackage{tikz}
\newcommand\multiplexer[1][1]{%
\begin{tikzpicture}[scale=#1]
\draw (0,0) -- (1,-0.5) -- (1,-1.25) -- (1.3,-1.25) -- (1,-1.25)-- (1,-2) -- (0,-2.5) -- (0,-1.75) -- (-0.3,-1.75) -- (0,-1.75) -- (0,-0.75) -- (-0.3,-0.75) -- (0,-0.75) -- (0,0);
\end{tikzpicture}
}
\begin{document}
\multiplexer[0.2]

This is a symbol: \multiplexer
\end{document}


I would like to use a symbol like this as a node shape, and if possible, like that, that the inputs and outputs can easily be connected.

I saw Creating node shapes, but that requires a lot of familiarity with PGF which I don't have. Isn't there another way or a workaround to somehow use this path as a shape?

There's no need to define a new shape; the shapes.geometric library already offers you the trapezium shape; with this, you can simply define a style; the already existing anchors for the trapezium can now be easily used for the in and out parts:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\tikzset{
multiplexer/.style={
draw,
trapezium,
shape border uses incircle,
shape border rotate=270,
minimum size=18pt
}
}

\begin{document}

\begin{tikzpicture}
\node[multiplexer]
(mul) at (0,1) {};
\draw (mul.top side) --++(10pt,0) ;
\draw (mul.south west) --++(-10pt,0) ;
\draw (mul.north west) --++(-10pt,0) ;
\end{tikzpicture}

\end{document}


• Your just do the job but it's not re-usable and extendable easily. – SdidS Nov 7 '17 at 7:59

You can use a pic for this.

\documentclass[tikz,border=7mm]{standalone}
\usetikzlibrary{calc,quotes}
\tikzset{
multiplexer/.pic ={
\coordinate (-out) at (.8,0);
\coordinate (-in-up) at (-0.8,.5);
\coordinate (-in-down) at (-0.8,-.5);
\draw[pic actions] (-.5,1.25) -- ++(1,-.5) -- ++(0,-1.5) -- ++(-1,-.5) --cycle;
\draw[pic actions] (.5,0) -- (-out) (-in-up) -- +(.3,0) (-in-down) -- +(.3,0);
\node{ \tikzpictext};
}
}

\begin{document}
\begin{tikzpicture}
\pic["One"] (one) {multiplexer};
\pic[fill=red,"Two"] (two) at (-3,2) {multiplexer};
\pic[fill=yellow,"Three"] (three) at (-3,-2) {multiplexer};
\draw (two-out) -| (one-in-up);
\draw (three-out) -| (one-in-down);
\end{tikzpicture}
\end{document}


• Is the width flexible/auto adjusted? – Sigur Jan 16 '15 at 21:38
• @Sigur No. This is not a shape. You can do it, but if you want to be realy like shape : use a shape. – Kpym Jan 16 '15 at 21:42
• @Sigur, to change the width, it's better to use new shape or nodes. However it requires a bit knowledge of PGF (and not Tikz). You can refer to part "101 Nodes and Shapes" from Tikz/PGF manual – SdidS Nov 7 '17 at 8:03