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.

1
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

4
  • This is good, but is there any way to have it positionable within an existing tikzpicture or circuitikz environment?
    – Jules
    Mar 9 '14 at 4:47
  • Never mind - figured it out. Thanks!
    – Jules
    Mar 9 '14 at 4:53
  • @Jules Could you explain what exactly you did to include it in a tikzpicture?
    – Nijin22
    Mar 22 '18 at 14:11
  • @Nijin22 sorry, can't remember off the top of my head, and my TeX-slinging days are pretty far behind me at this point. Have a relevant xkcd, though.
    – Jules
    Mar 23 '18 at 0:38
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

6
  • Nice :) But you don't need \scalebox. You can change the size of a picture by changing the value of \unitlength with \setlength{\unitlength}{<some amount>}. Sep 25 '18 at 20:10
  • You're welcome :) You could also put the <some amount> as an optional argument to the \mux command, so you don't have to use \setlength every time :) Sep 25 '18 at 20:23
  • @PhelypeOleinik Even better - you are great!
    – daniel
    Sep 25 '18 at 20:33
  • Not so much. You did all the work, I just complained :D Nice job by the way Sep 25 '18 at 20:34
  • @PhelypeOleinik This website is very nice! I hope to stay!
    – daniel
    Sep 25 '18 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.