4

I would like to draw a double line with small arrowheads on each of the lines.

How can I have an arrow pointing in one direction in the middle of one line and another on the other line, pointing in the opposite direction ?

It should look something like this:

------>-----

-----<------

I prefer achieving this using \draw to be able to join such segments nicely and to use other draw features such as bending.

The closest thing that I can think of doing is

   \documentclass[tikz,margin=1cm]{standalone}
   \usetikzlibrary{decorations.markings}

   \begin{document}
   \begin{tikzpicture}[
     doublearrow/.style={
       double,
       postaction={decorate},
       decoration={markings,mark=at position .85 with {\arrow{latex}}}
     }]
     \draw[doublearrow] (0,0) -> (0,1);
       \end{tikzpicture}
\end{document}, 

which is far from what I would like to achieve.

  • 1
    HI ! Could you show us what you try so far ? – flav Apr 13 '16 at 8:30
  • 1
    Hi, thanks a lot for the response. In this case, I don't even know where to start from because all that I found in the pgf & tikz manual are about putting an arrow that is centered with the line in the lateral direction. In the case of the double line, that means putting an arrow head in the middle of the two lines. – Mercan Apr 13 '16 at 8:40
  • Show us the code you begin to write and we could help you to improve. – flav Apr 13 '16 at 8:44
5

Here's one attempt using the markings decoration (48.5 Arbitrary Markings in the TikZ manual):

\documentclass[tikz,margin=1cm]{standalone}
\usetikzlibrary{decorations.markings}

\begin{document}
    \begin{tikzpicture}
        \tikzstyle{my arrow}=[
            postaction=decorate,
            decoration={
                markings,
                mark=at position #1 with {
                    \draw[->] (-.01pt,0) -- (0,0);
                },
            },
        ]

        % It works on bent paths
        \draw[my arrow=0.5] (0,0) to[bend right] (1,2);

        % You can have multiple arrows on a single path
        \draw[red,my arrow=0.25,my arrow=0.75] (1,2) -| (0,0);
    \end{tikzpicture}
\end{document}

output

EDIT: re-reading your question, could this be what you're looking for?

\documentclass[tikz,margin=1cm]{standalone}
\usetikzlibrary{decorations.markings}

\begin{document}
    \begin{tikzpicture}
        \tikzstyle{arrowed double line}=[
            double distance between line centers=3pt,
            postaction=decorate,
            decoration={
                markings,
                mark=between positions 10pt and -10pt step 20pt with {
                    \arrow[thin,yshift= 1.5pt,xshift=.8pt]{>}
                    \arrow[thin,yshift=-1.5pt,xshift=.8pt]{<}
                },
            },
        ]

        \draw[arrowed double line] (0,0) .. controls (1,4) and (-2,2) .. (1,2);
    \end{tikzpicture}
\end{document}

second result

  • Your second example in your answer is almost exactly what I wanted. I would like only a single arrow head per segment but I think I can achieve this myself. Thanks a lot for your help! – Mercan Apr 13 '16 at 9:26
  • 1
    @Mercan: If you find a way to get exactly one head per segment without manually tweaking coordinates, please share :-). Also note that I just edited my code to be a bit more elegant. I did not know about the \arrow command. – wrtlprnft Apr 13 '16 at 9:34
  • that's being slightly more challenging than I hoped but I will definitely share my solution if I have one. – Mercan Apr 13 '16 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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