6

Is there a TikZ library for drawing circuits like the following ones

enter image description here

6

Indeed there are. If you look at the TikZ manual there is a section starting on page 547 that describes all of the circuit libraries in great depth. Here is a quick quote showing the most common libraries:

enter image description here

Also of note is the circuitikz package (\usepackage{circuitikz}) - the documentation for that can be found here.

Some of your components I can't seem to find (I'm also in a bit of a rush...) but you can also create custom components. Ex:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[
    inout/.style={
      rectangle,
      draw,
      minimum size=1cm,
      inner sep=2pt,
     append after command={
        foreach \x in {1,...,4}{
            ($(\tikzlastnode.south west)!0.2*\x!(\tikzlastnode.north west)$) edge[draw] ++(-2mm,0mm) 
            ($(\tikzlastnode.south east)!0.2*\x!(\tikzlastnode.north east)$) edge[draw] ++(2mm,0mm) 
            }
        }
    }
  ]
    \node[inout] (d1) at (1,1) {in};
\end{tikzpicture}
\end{document}

which produces

enter image description here

(Code from this question.)

Hope this helps!

  • Could you explain how to add multiple input- and output wires to the box you produced? – user94293 Aug 10 '16 at 19:44
  • @user94293, I have added the wires. – heather Aug 10 '16 at 22:17
  • Could you add some explanation? In particular, what is the meaning of !0.2*\x!, the use of $, etc. Cf. also the question you asked and the answer by @percusse – user94293 Aug 11 '16 at 14:09
  • @user94293, I fixed the link to the question answered by percusse. To be absolutely honest, I'm pretty new to LaTeX. However, I fiddled with the code a bit, and I'm pretty sure that the piece code takes in the x value for the shape and multiplies it such that the legs are correctly placed, and it does so for each side (which is why there are two lines of code there). You can see this by changing 0.2 to 0.1. As for why the ! and $ are necessary, I'll look into it further. Suffice it to say that they are very necessary, to the point of producing no output if one of them are not included. – heather Aug 11 '16 at 14:21

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.