Sometimes I want to add a line indicating the distance between two points as in the example
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (0,3);
\coordinate (C) at (8,0);
\coordinate (D) at (5,1.125);
% drawing triangle
\draw (A) -- (B) -- (C) -- (A);
% drawing line in triangle
\draw [dashed] (5,0) -- (D);
% drawing d line
\draw (0,-0.5) -- node[below] {$d$} (8,-0.5);
\draw (0,-0.4) -- (0,-0.6);
\draw (8,-0.4) -- (8,-0.6);
% drawing x line
\draw (5.175,1.593) -- node[above, rotate=-20.556] {$x$} (8.175,0.468);
\draw (5.14,1.499) -- (5.21,1.686);
\draw (8.14,0.374) -- (8.21,0.561);
\end{tikzpicture}
\end{document}
But doing it like this is time consuming as there are a lot of calculations to do. Is there a way to do it automatically so that I can draw the lines with one command without calculations and autorotation? For example:
%drawing d line
\draw [offset=-0.5, amplitude=0.2] (A) -- node[below] {$d$} (C)
% drawing x line
\draw [offset=0.5, amplitude=0.2] (D) -- node[above] {$x$} (C)





|-|arrow tips will only touch the targeted points and will not be directly orthogonally above the points. (Related: Q111051) – Qrrbrbirlbel Sep 24 '22 at 20:24