5

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}

2 Answers 2

9

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}},
}
1
  • Thank you so much! That works exactly how I wanted. Commented Oct 9, 2018 at 23:49
8

Just a complement, an option in tikz Euclide, that has some ad hoc mark statements, decorations also available using scope for the desired marks.

RESULT:

enter image description here

MWE:

\documentclass[tikz,border=20pt]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{arrows.meta}
\usetkzobj{all}

\begin{document}
    \begin{tikzpicture}
    %Definindo os vertices
    %%The best way to define Axis is using polar notation:
    \tkzDefPoint(0,0){A} %The reference point
    \tkzDefShiftPoint[A](0:5){B}% POINT B 
    \tkzDefShiftPoint[A](40:4){D} %POIN D

    %%Find point C colinear at D from AB
    \tkzDefPointWith[colinear= at D](A,B) \tkzGetPoint{C} 

    %%Find point E colinear at C from DB
    \tkzDefPointWith[colinear= at C](D,B) \tkzGetPoint{E} 

    %Drawing modified style lines
    {%style only afects commands inside {}
        \tikzset{line style/.append style={<->},>={Stealth[scale=2.2,inset=0pt,angle'=20]}} 
            \tkzDrawLine[add=40pt and 40pt](A,B)
            \tkzDrawLine[add=40pt and 40pt](D,C)
            \tkzDrawLine[add=40pt and 40pt](A,D)
            \tkzDrawLine[add=40pt and 40pt](B,C)
    }
    \begin{scope}[decoration={markings,mark=at position .6 with {\arrow[scale=2]{>>}};}]
    \tkzDrawSegments[postaction={decorate},dashed](D,B C,E)
    \end{scope}


    %Drawing and label Points
    \tkzDrawPoints[color=blue,fill=blue,size=6pt](A,B,C,D)
    \tkzLabelPoints[color=blue,below=5pt,inner sep=0](A,B,C,D)

    %Mark Segments
    \tkzMarkSegments[mark=||](A,B D,C)
    \tkzMarkSegments[mark=|](B,C A,D)
    \end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .