1

The following TikZ code

\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}

\coordinate (a0) at (4,3);

\coordinate (a1) at (1.25,0.75);
\coordinate (a2) at (3,-1);

\draw[dashed] (a1) -- node[pos=0.55] (a3) {} (a2 |- a0);

\draw[thick,-{Straight Barb}] (a1) -- node[pos=0.5, above=0.4em] {a} (a3);

\draw[-{Straight Barb}] (a1) -- (a1 |- a3);
\draw[-{Straight Barb}] (a1) -- (a1 -| a3);

\draw[dashed] (a1 |- a3) -- (a3);
\draw[dashed] (a1 -| a3) -- (a3);

\end{tikzpicture}

\end{document}

generates this output:

enter image description here

I would like to place an arrow vector along a diagonal line, ending at a custom point on the diagonal.

In the image, the vector should perfectly reach the intersection of the dashed lines. With

\draw[dashed] (a1) -- node[pos=0.55] (a3) {} (a2 |- a0);

I was expecting that a node labelled a3 was placed at position 0.55 of the above diagonal length, and so that the subsequent

\draw[-{Straight Barb}] (a1) -- (a1 |- a3);
\draw[-{Straight Barb}] (a1) -- (a1 -| a3);

could meet exactly this point.

How to accomplish this?

BowPark
  • 1,213
  • 2
    coordinate[pos=0.55] (a3) instead of node[pos=0.55] (a3) {}. A node has a size, a line drawn to a node stops at the node border. – Torbjørn T. Apr 05 '18 at 12:02
  • Essentially same as https://tex.stackexchange.com/questions/99398 or https://tex.stackexchange.com/questions/97887 I guess. – Torbjørn T. Apr 05 '18 at 12:07
  • @TorbjørnT. Thank you, it works. If you want to write an answer, I'll choose it. – BowPark Apr 05 '18 at 12:08
  • @TorbjørnT. Yes, same solution as in the linked answers, even if here the initial problem is different (tracing a vector along a diagonal). – BowPark Apr 05 '18 at 12:09
  • 1
    I think the problem is the same, it's about drawing a line to a point defined by a node, but having the line terminate early because it stops at the edge of the node. The purpose is different, the problem is not. Unless you disagree I'll close the question as duplicate. – Torbjørn T. Apr 05 '18 at 12:14
  • Actually, you are right. Ok, mark the question as needed. – BowPark Apr 05 '18 at 12:17

0 Answers0