1

I'm new in Latex, I try to draw an decoder and I don't know how to add the inputs/outputs (like the image).

  • Decoder 2:4
  • 2 inputs
  • 4 outputs

    \documentclass{article}
    \usepackage{circuitikz,siunitx}
    \usetikzlibrary{circuits.logic.IEC}
    
    \begin{document}
    
    \begin{circuitikz}[circuit logic IEC] 
    
    \node[
          and gate,
          inputs={nnn},
          and gate IEC symbol={},
          text height=5cm,
          text width=2cm,
         ] (A) {};
    
     (A.in 1) node [anchor=east] {A}     %not working
     (A.in 2) node [anchor=east] {B}     %not working
    
    \end{circuitikz}
    
    \end{document}
    

enter image description here

enter image description here

10
  • 1
    See also your previous question (tex.stackexchange.com/questions/433568/…) and the answer giving there. What did you try? explain where the problem lies.
    – albert
    May 27, 2018 at 7:54
  • 2
    It is good that you admit that it is for a homework, thanks for your honesty. But if it's for your homework you should really show some effort. Take a look at the link @albert posted and try to accomplish what you need. If you face issues while doing so, you can ask a question about that specific issue with the code you got so far. As of now you might not get any or many answers.
    – Skillmon
    May 27, 2018 at 8:13
  • 1
    @Skillmon it isn't a Latex home work. it's just me who want to use Latex. What I m asking for is just the code to draw the same drawing in the image. May 27, 2018 at 11:08
  • 4
    Honestly, this is not a draw this for me for free service.
    – Johannes_B
    May 27, 2018 at 11:13
  • 1
    It is really not reasonable to change questions in ways which invalidate existing answers. Your edit does not quite do this, but it means that my answer is now at best a partial one, whereas it fully addressed the original question. Please roll back, read the docs, have a go and post a new question with your attempt if you need help using the logic circuits libraries.
    – cfr
    May 28, 2018 at 1:27

1 Answer 1

3

You seem to be confusing circuitikz with the circuits libraries bundled with TikZ itself. The logic gates can handle multiple inputs, if you follow the examples in the TikZ manual, but not multiple outputs. They are, after all, logic gates. (And I don't think TikZ knows about fuzzy logics or quantum logical states.)

However, you can draw a block with lines going in and out of it very easily using TikZ itself.

For example,

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
  \node[
    draw,
    text height=5cm,
    text width=2cm,
  ] (A) {};
  \foreach \i in {60,30,-30,-60}
    \draw (A.\i) -- ++(1,0);
  \foreach \i in {-120,120}
      \draw (A.\i) -- ++(-1,0);
\end{tikzpicture}
\end{document}

block with inputs & outputs: basic Ti*k*Z

2
  • Thank you for the answer. One last thing how can I add an OR gate to the outputs? check the update image (second image). May 28, 2018 at 1:20
  • @AdilBlanco The TikZ manual shows you how to add logic gates. Please try to modify an example there. I answered one question. You are now asking a different question about a library which I do not personally use. The documentation is not long, however, and looks to be straightforward, so I suggest reading it. If you still have trouble, post a new question showing what you've tried (and linking this question if appropriate).
    – cfr
    May 28, 2018 at 1:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .