2

I am trying to use tikz to draw a quiver and I need to draw arrows of the form =-> and -=> between two nodes. What is the best way to do it? Any help is appreciated.

6
  • Welcome! What have you tried? I guess you mean you want to draw a double line followed by a single line with an arrow or a single followed by a double with an arrow? Those aren't really arrow tips, but the TikZ manual explains how to use tips and arrows.meta. Take a look.
    – cfr
    Oct 17, 2016 at 1:31
  • Your description is correct. I know that to draw an arrow you need \draw [->] (a) -- (b), but I am not sure how to change it between single edge and double edge in the middle of a line. I am new to tikz and I don't know where to start. I will look into what you said above. Thanks.
    – Daps
    Oct 17, 2016 at 1:38
  • If you post the code showing what you can do, it is easier to know where to start helping.
    – cfr
    Oct 17, 2016 at 1:40
  • You'll have to draw two lines, I think. You can switch in the middle. But you could use an edge for the second part so it is all done in one \path or \draw command.
    – cfr
    Oct 17, 2016 at 1:41
  • The following is what I have now: \tikz{ \node (a) at (0,0) [] {$\bullet$}; \node (b) at (2,0) [] {$\bullet$}; \draw [=->] (a) -- (b); }
    – Daps
    Oct 17, 2016 at 1:44

3 Answers 3

2

Is this close to what you want?

\documentclass[tikz, border=5pt]{standalone}
\usetikzlibrary{decorations.pathreplacing, arrows}

\tikzset{
  -z>/.style={
    decoration={
      show path construction,
      lineto code={
        \path (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast) coordinate[pos=#1] (mid);
        \draw (\tikzinputsegmentfirst) -- (mid);
        \draw[double, -implies] (mid) -- (\tikzinputsegmentlast);      }
    },decorate
  }, -z>/.default=.5,
  z->/.style={
    decoration={
      show path construction,
      lineto code={
          \path (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast) coordinate[pos=#1] (mid);
                \draw[double] (\tikzinputsegmentfirst) -- (mid);
                \draw[->] (mid) -- (\tikzinputsegmentlast);
      }
    },decorate
  }, z->/.default=.5,
}

\begin{document}
\begin{tikzpicture}
  \draw [-z>] (0,0) -- (1,0);
  \begin{scope}[red, thick]
    \draw [z->=.3] (0,-.2) -- (1,-.4);
  \end{scope}
\end{tikzpicture}
\end{document}

styled lines

I don't think you can have = as part of a style name, so I've denoted a double line with z. Note that the arrowheads aren't quite the same for the two styles, although this can probably be fixed. For some reason, styles directly on the \draw commands don't get reliably passed to the decorations, but if you need to style it further you can use a scope.

1
  • This is exactly what I am looking for. Thanks a lot!
    – Daps
    Oct 17, 2016 at 15:30
5

You can do something like this, which uses an edge to draw the second line with the arrow tip.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
  \draw  (0,0) -- (1,0) edge [double, -{Implies}] ++(10pt,0);
  \draw [double]  (0,-.25) -- (1,-.25) edge [double=none, ->] ++(10pt,0);
\end{tikzpicture}
\end{document}

split lines

But I'm not convinced I understand what you're trying to do.

2
  • Thanks a lot! It almost does what I want, except I need the transition between the single line to the double line happen right at the middle of the edge, and instead of specifying the transition point I would like to only specify the end points of the line...
    – Daps
    Oct 17, 2016 at 2:00
  • Just make the edge smaller e.g. use 5pt rather than 10pt which will be the same as if you did the switch halfway along the edge. It would not be easy to create this in a way that required only specifying the end points and was at all convenient to use. It's certainly possible, but you need an expert ;).
    – cfr
    Oct 17, 2016 at 2:50
3

You can use the midway key (or pos key) to coordinate or node to find the midpoint of an edge, and then draw the two halves, or redraw the double half on top of the single half. Here are some basic examples of doing this. (Note that cfr's use of the arrows.meta tikz library would produce better arrowheads.)

\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[black!10] (-1,0) grid (3,3);
\path (0,0) node (A)[draw,circle] {A} -- (3,1) node[draw,circle](B){B}  (A)--(B) coordinate[midway](mAB);
\path (A) -- (-1,2) node[draw,circle] (C) {C}  (A)--(C) coordinate[pos=0.5](mAC);
\draw[double,line cap=round] (A)--(mAB); \draw[->] (mAB)--(B);
\draw (A)--(mAC); \draw[double,->] (mAC)--(C);
\draw[thick] (3,3)coordinate(A)--(1,1)coordinate(Z) coordinate[midway](M); \draw[double,->] (M)--(Z);
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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