# How to draw a multiplexer 8 to 1 with circuitikz

How can I draw a multiplexer 8 to 1 with tikz or circuitikz? A hand-drawn example is shown below.

• You really need to improve your hand-drawing :) – picasso Mar 16 '15 at 16:36

With TiKz:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\draw (0,0)coordinate (O)--++(30:1)coordinate (A)--++(90:4)coordinate (B)--++(150:1)coordinate (C)--cycle;
\draw ($(A)!0.5!(B)$)--++(0:1)node[right]{$F$};
\draw ($(O)!0.5!(A)$)--++(-90:1)--++(180:2)node[left]{$b$};
\draw ($(O)!0.25!(A)$)--++(-90:0.5)--++(180:1.75)node[left]{$a$};
\draw ($(O)!0.75!(A)$)--++(-90:1.5)--++(180:2.25)node[left]{$c$};
\foreach \y/\t in {0.1/1,0.2/2,0.3/3,0.4/4,0.5/5,0.6/6,0.7/7,0.8/8} {
\draw ($(C)! \y*1.1 !(O)$)--++(180:1) node[left] {$X \t$};}
\end{tikzpicture}

\end{document}


• how can I use this as a reusable fillable shape? e.g. instead of rectangle or circle? – Jason S May 13 '15 at 17:21
• @JasonS, if I understood right you, use \filldraw instead of \draw ,e.g. \filldraw [color=](0,0)coordinate (O)... – ferahfeza May 14 '15 at 16:59
• no, it was more of how to save it as a shape and just be able to do \node [mux, draw](A){};. But I found trapezium so I'm all set. – Jason S May 16 '15 at 23:39
• Maybe this help: tex.stackexchange.com/a/75516/31034 – ferahfeza May 17 '15 at 9:33

The circuits.logic.IEC library offers an and gate that gives you as many input anchors as required:

\documentclass{article}
\usepackage{circuitikz}
\usetikzlibrary{circuits.logic.IEC,calc}

\begin{document}

\begin{circuitikz}[circuit logic IEC]
\node[and gate,inputs={nnnnnnnn},and gate IEC symbol={},text height=3cm,
] (A) {};
\foreach \Valor in {1,...,8}
{
\draw  ([xshift=-10pt]A.input \Valor) node[left] {$I_{\Valor}$} -- (A.input \Valor);
}
\draw (A.output) -- ++(10pt,0) node[right] {$F$};
\draw ( $(A.south west)!0.25!(A.south east)$ ) -- ++(-90:0.25) |- ++(-10pt,0) node[left] {$a$};
\draw (A.south) -- ++(-90:0.5) |- ++(-15pt,0) node[left] {$b$};
\draw ( $(A.south west)!0.75!(A.south east)$ ) -- ++(-90:0.75) |- ++(-20pt,0) node[left] {$c$};
\end{circuitikz}

\end{document}