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'm trying to draw two arrows between nodes as follows:

A ------> B
  <--/---

The arrows should be parallel, in opposite directions but not on top of each other. (I can bend the arrows but that's not what I'm after.)

What's the cleanest way to do this in TikZ? And can I have just one of the arrows "struck out" as in the example?

share|improve this question
    
For the "strike out", take a look at the answers to the question: tex.stackexchange.com/q/3161/86 –  Andrew Stacey May 12 '11 at 18:26
add comment

2 Answers

With PSTricks. Unfortunately, no option to change the radius of \circlenode to be uniform.

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
\psset{arrows=->,arrowinset=0}
\begin{document}
\begin{pspicture}[showgrid](5,2)
    \rput(1,1){\circlenode{Left}{left}}
    \rput(4,1){\circlenode{Right}{right}}
    \ncline[offset=5pt]{Left}{Right}
    \ncline[offset=5pt]{Right}{Left}
    \ncput{\psline[arrows=-](5pt;45)(5pt;-135)}
\end{pspicture}
\end{document}
share|improve this answer
add comment

Here is an idea that might answer both your questions. It uses yshift to move the start and end points of the two paths up/down by 5pt. The result could be further improved by shifting the start/end points along the x axis in order for the paths to really be in contact with the nodes' circles.

A custom TikZ style is used to add a strike-through marking at the middle of the second path. This could be parameterized further to allow moving the marking to any position on the path etc.

I cannot tell whether this is the most elegant solution though.

\documentclass{minimal}

\usepackage{tikz}

\usetikzlibrary{decorations,decorations.markings}

\tikzset{
  strike through/.style={
    postaction=decorate,
    decoration={
      markings,
      mark=at position 0.5 with {
        \draw[-] (-5pt,-5pt) -- (5pt, 5pt);
      }
    }
  }
}

\begin{document}
\begin{tikzpicture}
  \node[draw,circle] (foo) at (0,0) { foo };
  \node[draw,circle] (bar) at (4,0) { bar };

  \draw[>=latex,->]                ([yshift= 5pt] foo.east) -- ([yshift= 5pt] bar.west);
  \draw[>=latex,<-,strike through] ([yshift=-5pt] foo.east) -- ([yshift=-5pt] bar.west);
\end{tikzpicture}
\end{document}

Here is how it looks like:

Screenshot of the result

share|improve this answer
7  
Note that you can apply simple shifts on coordinates by using the yshift, xshift or shift options on the coordinate: ([yshift=2pt]foo.east) instead of ($ (foo.east) + (0, 2pt) $). This is often not known. It does not require the calc library. –  Martin Scharrer May 12 '11 at 16:16
    
Interesting, I didn't know that syntax. I tried yshift in the arguments to \draw as well as after -- (also tried edge instead of --) but neither of them worked. Thanks for the hint. –  Jannis Pohlmann May 12 '11 at 16:21
1  
@Jannis: If you operate on named coordinates instead of direct ones, you further need transform canvas. –  Andrey Vihrov May 12 '11 at 16:22
    
@Andrey: Ah, alright. –  Jannis Pohlmann May 12 '11 at 16:24
1  
@Andrey: It seems to be an issue if you use the node name without an anchor, because then the border anchor is taken which depends on the position of the target coordinate. That's basically the difference between (A) and (A.center). It seems to work without transform canvas if you use an anchor like (A.west). –  Martin Scharrer May 12 '11 at 18:12
show 7 more comments

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.