2

I want to define a 2-to-1 multiplexer symbol, defined by 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)

As a new command, so that it's easier to use (as you can imagine, movement and scaling is borderline impossible). What would be the best way to do this?

For the record, this is just an example; I'm aware that this particular MUX is missing a select in.

Jules
  • 573

2 Answers2

3
\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}

enter image description here

1

@Bobyandbob suggested I answer this.

The symbol can be drawn with picture and scale with optional parameter (thank you @PhelypeOleinik!).

\documentclass{standalone}

\newcommand{\mux}[1][1pt]{%
    \setlength{\unitlength}{#1}
    \begin{picture}(60,80)
        \put(20,20){\line(0,1){40}}
        \put(40,30){\line(0,1){20}}
        \put(20,20){\line(2,1){20}}
        \put(40,50){\line(-2,1){20}}
        \put(40,40){\line(1,0){6}}
        \put(20,30){\line(-1,0){6}}
        \put(20,50){\line(-1,0){6}}
    \end{picture}
}

\begin{document}

\mux

\mux[5pt]

\end{document}

enter image description here

daniel
  • 1