4

Building on the answer http://tex.stackexchange.com/a/304044/103076 by wrtlprnft, I have the following code

   \documentclass[tikz,margin=1cm]{standalone}
   \usetikzlibrary{decorations.markings}
   \begin{document}
   \begin{tikzpicture}
        \tikzstyle{arrowed double line}=[
            dashed, 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) --  (1,2);
    \end{tikzpicture}
\end{document}

which produces this:

enter image description here

I am unhappy with the faint transverse lines between the dashes. I don't even know why tikz decides to draw them.

Is there a way to get rid of them?

Thanks in advance to all replies.

PS the same thing occurs at the caps of double solid lines

Omer
  • 85
  • 2
    i'm not a regular user of tikz, so this is just a guess. this could be an artifact from drawing a thick line, then blanking out the center portion. someone who is more familiar with the tikz internals could confirm or refute this. – barbara beeton Jul 30 '16 at 13:41
  • Probably a problem with the anti-aliasing, see also the comments on this answer: http://tex.stackexchange.com/a/251562/82624 – Stefan Braun Jul 30 '16 at 20:56
  • @barbarabeeton Yes. All double lines are really one line on top of a thicker one, if that's what you had in mind. – cfr Jul 31 '16 at 03:35
  • Thank you very much for the comments. That's interesting. Then I believe the only solution would be to redraw everything with a method that doesn't cause this. – Omer Jul 31 '16 at 09:27
  • @cfr -- yes, that's exactly what i had in mind. thanks for checking. what would happen if this were on a colored background? presumably, the overlay line could be drawn in the background color, but is it? – barbara beeton Jul 31 '16 at 13:14
  • @barbarabeeton Not by default, but you can change the colour used for the second line. – cfr Jul 31 '16 at 13:57
  • @Mercan You can draw each bit separately e.g. draw the dashed lines. Then draw a thinner, non-dashed line down the middle. Then use a decorated path to add the arrows. – cfr Jul 31 '16 at 14:08

1 Answers1

3

You could try this:

\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
  [arrowed double line/.style={% \tikzstyle is deprecated
  preaction={
    draw=black,
    dashed,
    double distance between line centers=3pt,
    line width=.4pt,
  },
  draw=white,
  line width=3pt,
  postaction={
    decorate,
  },
  decoration={
    markings,
    mark=between positions 10pt and -10pt step 20pt with {
      \arrow [thin,black,yshift= 1.5pt,xshift=.8pt]{>}
      \arrow [thin,black,yshift=-1.5pt,xshift=.8pt]{<}
    },
  },
  }]
  \path[arrowed double line] (0,0) --  (1,2);
\end{tikzpicture}
\end{document}

manual construction

EDIT

If you want to remove traces at the ends of the lines, you can use shorten with a negative dimension for just the white line. Obviously, this needs a little care to avoid painting over anything already in the picture.

For example,

\begin{tikzpicture}
  [arrowed double line/.style={% \tikzstyle is deprecated
    preaction={
      draw=black,
      dashed,
      double distance between line centers=3pt,
      line width=.4pt,
      shorten >=0pt,
      shorten <=0pt,
    },
    draw=white,
    line width=3pt,
    shorten >=-.1pt,
    shorten <=-.1pt,
    postaction={
      decorate,
    },
    decoration={
      markings,
      mark=between positions 10pt and -10pt step 20pt with {
        \arrow [thin,black,yshift= 1.5pt,xshift=.8pt]{>}
        \arrow [thin,black,yshift=-1.5pt,xshift=.8pt]{<}
      },
    },
  }]
  \path[arrowed double line] (0,0) --  (1,2);
\end{tikzpicture}

produces the following line ending:

end of line

cfr
  • 198,882
  • That's great! Thank you very much. I wasn't sure if that white band was at all possible. Is it possible to extend it a little such that the caps go away as well? – Omer Aug 01 '16 at 15:32
  • You can use shorten >= and shorten <= with negative values for the white line. That should probably work, but you'd need to be careful to avoid painting over anything in the way, of course! – cfr Aug 01 '16 at 19:34
  • @Mercan Please see edit. – cfr Aug 01 '16 at 21:26