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 want to draw a diagram as follows: enter image description here

This is my tikz code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}

\begin{document}


\tikzstyle{int}=[draw, minimum size=4em]
\tikzstyle{init} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]
    \tikzstyle{line} = [draw, -latex']
    \node [int] (a) { $x^2$ };
   \node [int] (b) [right of=a] { $x^1$ };
    \node [int] (c) [right of=b] { $x^0$ };
    % \coordinate[right=1.75cm of a] (a1)  {};

    \path[->] (b) edge node { } (a);

\end{tikzpicture}

\end{document}

Output is:

enter image description here

How do I make those XOR symbols in tikz?

share|improve this question
2  
Is \node [int] (c) [shape=circle, draw, right of=b] {\Huge$+$}; what you are looking for? And replaced you existing node (c) with \node [int] (d) [right of=c] { $x^0$ }. –  Peter Grill Oct 2 '12 at 5:04
    
You can use $\oplus$... –  Paul Gaborit Oct 2 '12 at 6:23
    
Qrrbrbirlbel's answer is good, but look at How to center a typewriter (ttfamily) '+' in case you want to use another font. –  Ignasi Oct 2 '12 at 7:01
    
Notice that \tikzstyle is deprecated as per Should \tikzset or \tikzstyle be used to define TikZ styles? –  Claudio Fiandrino Oct 2 '12 at 7:45
add comment

1 Answer

up vote 3 down vote accepted

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}
\begin{document}

\tikzstyle{int}     = [draw, minimum size=4em]
\tikzstyle{init}    = [pin edge={to-,thin,black}]
\tikzstyle{XORgate} = [draw,circle]
\tikzstyle{line}    = [draw, -latex']

%\pgfkeyssetvalue{/tikz/node distance}{4cm}           % needs next line to work
%\pgfkeysgetvalue{/tikz/node distance}{\nodedistance} % but than I can just say \def…
\newcommand*\nodedistance{4cm}
\begin{tikzpicture}[node distance=\nodedistance,auto,>=latex', scale = 0.75, transform shape]
    \tikzstyle{line}=[draw, -latex']
    \node [int] (a) { $x^2$ };
    \node [int,right of=a] (b) { $x^1$ };
    \node [int,right of=b] (c) { $x^0$ };
    \node [XORgate] at ($(b)!.5!(c)$) (XOR-b-c) {\large +};
    \node [XORgate] at ($(b)!1.5!(a)$) (XOR-aa) {\large +};
    \coordinate [below of=XOR-aa,node distance=.5*\nodedistance] (below-XOR-aa);
    \node [above of=XOR-aa,node distance=1.5cm,text width=1.5cm,anchor=south,align=center] (input) {Message\\Input};
    \path[line] (c) edge (XOR-b-c)
                (XOR-b-c) edge (b)
                (b) edge (a)
                (a) edge (XOR-aa)
                (XOR-aa) -- (below-XOR-aa) -| ($(c) + (.5*\nodedistance,0pt)$) -- (c)
                (input) edge (XOR-aa)
                ($(XOR-b-c)+(0,-.5*\nodedistance)$) -- (XOR-b-c);
\end{tikzpicture}
\end{document}

Output

Output

share|improve this answer
add comment

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.