Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have to draw a diagram and would like to fit it on a page, thus i have not much space. Therefore I have to "stack" some gates, however it would be beneficial if I could put the outputs of the logic gate on the left and the inputs on the right side. Is there a way to flip a nodes shape (the label & still needs to be readable the right way round)?

Sketch of the issue (left what I would like, right alternative for the time beeing): sketch of the issue, left optimal, right current solution

(I did not put much time into the simplified doodle, but I think it illustrates the issue, how to get the upper and gate)

edit: in my case a 3 input and will do, however I am curious about solutions and not "workarrounds".

MWE: Simply an and gate. Question, how do i turn the input and output sides arround (the order of input n anchors can be upside down)

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}

\usetikzlibrary{circuits}
\usetikzlibrary{circuits.logic}
\usetikzlibrary{circuits.logic.IEC}
\begin{document}

\begin{tikzpicture} [circuit logic IEC,
every circuit symbol/.style={
logic gate IEC symbol color=black,
fill=blue!20,draw=blue,very thick}]

    \node (and)[and gate]{};
    \draw (and.output) -- ++ (1,0);
    \draw (and.input 1) -- ++ (-1,0);
    \draw (and.input 2) -- ++ (-1,0);

\end{tikzpicture}

\end{document}
share|improve this question
    
Can you add a minimal working example? –  Qrrbrbirlbel Jun 19 '13 at 12:51
    
@Qrrbrbirlbel: done, see above for mwe –  ted Jun 19 '13 at 13:19
    
Alright, rotate=180 and its clone point left also rotate the &. My fix would be to remove that & and simply put a label where it usually would be. –  Qrrbrbirlbel Jun 19 '13 at 13:29

1 Answer 1

up vote 3 down vote accepted

Alright, this is the idea of a solution. As the label option is only a wrapper for append after command we can use \tikzlastnode and extract the proper dimensions and place the & (or whatever symbol is used) appropriately.

Code

\documentclass[12pt,tikz,convert=false]{standalone}
\usepackage{tikz}
\usepackage{etoolbox}

\usetikzlibrary{circuits.logic.IEC}

% from: http://tex.stackexchange.com/a/106796/16595
\makeatletter
%\tikzset{anchor/.append code=\let\tikz@auto@anchor\relax}
\tikzset{inside/.code=\preto\tikz@auto@anchor{\pgf@x-\pgf@x\pgf@y-\pgf@y}}
\tikzset{
  point left/.append style={
    label/.expanded={[inside, very thick, inner sep=2\pgflinewidth]south:\pgfkeysvalueof{/pgf/and gate IEC symbol}},
    and gate IEC symbol=,
  }
}
\makeatother

\begin{document}

\begin{tikzpicture}[
  circuit logic IEC,
  every circuit symbol/.style={
    logic gate IEC symbol color=black,
    fill=blue!20,
    draw=blue,
    very thick
  }
]

  \node[and gate, point left] (and)[]{};
  \draw (and.output) -- ++ (-1,0);
  \draw (and.input 1) -- ++ (1,0);
  \draw (and.input 2) -- ++ (1,0);
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
    
thanks for the awnser. I have a hard time searching preto .Since I have no latex guide yet, could you either explain what preto does or where I can read about it/recommend a tex guide explaining it (preferebly available online). –  ted Jun 19 '13 at 14:29
    
found out that pretois part of the etoolbox to prepend code, however I am still wondering, why you changed the place where you supply the arguments to the \node command from after the nameto before, is there a reason? –  ted Jun 19 '13 at 14:48
1  
@ted The inside solution comes from the linked question. — No special reason but my own style. There is no difference where you place the options for a node as long as they are between node (or \node) and the node text {}. I like to gather them directly behind the node/\node text as I find the code more readable that way. –  Qrrbrbirlbel Jun 19 '13 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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