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.

Possible Duplicate:
Double arrow in TIKZ?

\begin{tikzpicture}
  [->,>=stealth',shorten >=1pt,auto,node distance=1.5cm,semithick,font=\tiny]
  \tikzstyle{every state}=
     [fill=none,draw=black,text=black, text centered, text width=0.5cm]


  \node[state] (A) {G};
  \node[state] (B) [right of=A] {B};

  \path (A) edge node {} (B);
  \path (B) edge  node {} (A);

\end{tikzpicture}

This is my current code, but a double ended arrow appears between A and B, any idea to make it two distinct arrows?

share|improve this question
    
Hi Concept, welcome to TeX.sx! I believe you may find an answer at the question I linked to above (the key is to use the [yshift=...] in your coordinates). If that doesn't answer your question, let us know. –  Jake Nov 18 '11 at 6:34
    
Nope, \path (B) edge node[yshift=10mm]{} (A); doesn't want to work, although I don't think that's the right syntax. –  Concept Nov 18 '11 at 7:29
    
Welcome to TeX.sx! Please always add a full but minimal working example (MWE) that illustrates your problem, not just the tikzpicture. This ensure that all libraries as included and allows people to simply copy & paste your code, in order to test their solutions. –  Martin Scharrer Nov 18 '11 at 8:08
    
@Concept: The shift would go on an anchor you specify. So in your case it would become \draw ([yshift=2pt] A.east) -- ([yshift=2pt] B.west); and then a negative shift on the second line. Note that, even though this works fine for rectangles, it causes problems for nodes where the contact edge is not straight. Since this just puts the line at a vertical offset from the west and east anchors and won't account for the shape, it won't stay on the border. It is a mystery to me why you have an empty node at the edge by the way. –  Roelof Spijker Nov 18 '11 at 8:35
add comment

marked as duplicate by Jake, N.N., Werner, Roelof Spijker, lockstep Nov 26 '11 at 16:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 11 down vote accepted

You can use [yshift=<distance>] to offset your arrows. This will only work if you specify a node anchor (so for instance something like ([yshift=1ex]A.center)).

Here's your example with shifted arrows. Note that I removed the empty nodes you created with node {}, they're not necessary for drawing the arrows:

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{automata,arrows}

\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=1.5cm,semithick,font=\tiny]
  \tikzstyle{every state}=[fill=none,draw=black,text=black, text centered, text width=0.5cm]


  \node[state] (A) {G};
  \node[state] (B) [right of=A] {B};

  \path ([yshift=1ex]A.east) edge ([yshift=1ex]B.west);
  \path ([yshift=-1ex]B.west) edge ([yshift=-1ex]A.east);

\end{tikzpicture}

\end{document}

If you want the arrows to start on the edge, you could use the A.<angle> anchors, which specify points on the edge of your nodes, with A.0 being the right-hand edge, A.90 the top, and so on. I would also use the \draw (...) -- (...); syntax for drawing the arrows in this case, since it's more compact and you don't need the edge notation here.

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{automata,arrows}

\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=1.5cm,semithick,font=\tiny]
  \tikzstyle{every state}=[fill=none,draw=black,text=black, text centered, text width=0.5cm]


  \node[state] (A) {G};
  \node[state] (B) [right of=A] {B};

  \draw (A.-25) -- (B.205);
  \draw (B.-205) -- (A.25);

\end{tikzpicture}

\end{document}
share|improve this answer
    
Boom! Thankyou very much :D –  Concept Nov 18 '11 at 9:32
add comment

In this case, with circular nodes of equal size, you could also use the <node name>.<angle> syntax, I suppose. This more or less eliminates the problem wh1t3 mentioned in his comment.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata,arrows}

\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=1.5cm,semithick,font=\tiny]
  \tikzstyle{every state}=[fill=none,draw=black,text=black, text centered, text width=0.5cm]


  \node[state] (A) {G};
  \node[state] (B) [right of=A] {B};

  \path (A.10) edge  (B.170);
  \path (B.190) edge  (A.-10);
\end{tikzpicture}

enter image description here

share|improve this answer
add comment

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