7

I need to draw an arrow midway in a line.
MWE:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
        \draw(1,1) -- (1,17);
        \draw(1,17)--(7,17)--(12,12)--(9,9);
        \draw (12,12)--(1,1);

        \coordinate (start) at (6,6);
        \coordinate (reflection) at (1,11);
        \coordinate (end) at (7,17);
        \draw [red] (start)--(reflection)--(end); 
        \node (b) at (0.7,11) {b};
        \node (c) at (7,17.2) {c};
        \node (a) at (6.1,5.9) {a};
    \end{tikzpicture}
\end{document}

I need an arrow both between node (a) and (b) and between (b) and (c), and both arrows should be midway.
I tried something like

\draw [red] (start) edge [->] (reflection) (reflection) edge [->] (end)(end); 

but in this way the arrows are at the end of the segment.

Current: current

4

1 Answer 1

8

I guess that you looking for the following:

enter image description here

For arrows heads in the middle of line is used decorations.markings TikZ library:

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                decorations.markings
                }

\begin{document}
    \begin{tikzpicture}[
->-/.style = {decoration={markings,
              mark=between positions 0.25 and 0.75 step 0.5 with {\arrow{Triangle[scale=1.2]}}},
              postaction={decorate},
              semithick, draw=red
              },
                        ]
\draw (1,1) |- (7,17)--(12,12) -- (1,1);

\draw [->-] (6,6)   coordinate[label=-45:a] (a) -- 
            (1,11)  coordinate[label=180:b] (b) -- 
            (7,17)  coordinate[label=c]     (c);
    \end{tikzpicture}
\end{document}

As you can see, I simplify drawing black lines. However, you can stick with your way of its drawing.

1
  • thank you that what i was looking for
    – john
    May 31 at 16:13

You must log in to answer this question.

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