[Tex/LaTex] Place parallel line markers on parallel lines

paralleltikz-pgf

I'm trying to add the > and >> on the two sets of parallel lines and having no luck.

\documentclass{scrreprt}
\usepackage{tikz}

\begin{document}


\begin{tikzpicture}[scale=1,xscale=2]
  \coordinate (A) at (0,0);
  \coordinate (B) at (2,2.5);
  \coordinate (C) at (4,2.5);
  \coordinate (D) at (2,0);
  \draw[<->,thick,shorten >=-60pt,shorten <=-60pt] (A) -- (B)node[midway]{SINGLE};
  \draw[<->,thick,shorten >=-60pt,shorten <=-60pt] (C) -- (D)node[midway]{SINGLE};
  \draw[<->,thick,shorten >=-60pt,shorten <=-60pt] (A) -- (D)node[midway]{DOUBLE};
  \draw[<->,thick,shorten >=-60pt,shorten <=-60pt] (B) -- (C)node[midway]{DOUBLE};
\end{tikzpicture}

\end{document}

Best Answer

You can use a decoration to do this. The code below defines two new arrow types ->- and ->>- that do what you want

enter image description here

Presumably the arrows stack because these are decorations.

Here is the code:

\documentclass{scrreprt}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{%
  ->-/.style={decoration={markings, mark=at position 0.5 with {\arrow{>}}},
              postaction={decorate}},
  ->>-/.style={decoration={markings, mark=at position 0.5 with {\arrow{>>}}},
               postaction={decorate}},
}

\begin{document}


\begin{tikzpicture}[scale=1,xscale=2]
  \coordinate (A) at (0,0);
  \coordinate (B) at (2,2.5);
  \coordinate (C) at (4,2.5);
  \coordinate (D) at (2,0);
  \draw[<->,thick,shorten >=-60pt,shorten <=-60pt,->-] (A) -- (B);
  \draw[<->,thick,shorten >=-60pt,shorten <=-60pt,->-] (D) -- (C);
  \draw[<->,thick,shorten >=-60pt,shorten <=-60pt,->>-] (A) -- (D);
  \draw[<->,thick,shorten >=-60pt,shorten <=-60pt,->>-] (B) -- (C);
\end{tikzpicture}

\end{document}

Notice that I had to reverse the code for the D-C line. Alternatively, you could use -<- if you add the definition:

\tikzset{%
  -<-/.style={decoration={markings, mark=at position 0.5 with {\arrow{<}}},
              postaction={decorate}},
}