0

The code below shows the length of the diagonal in pt, how to show it as cm with 2 digits?

\documentclass[convert,border=10mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows, calc}
\begin{document}
\begin{tikzpicture}
  \coordinate (A) at (0,0);
  \coordinate (B) at (3cm,3cm);
    \draw[latex-latex] (A) -- (B) node[pos=.5,yshift=.2cm, inner sep=1mm, outer sep=0mm,
    insert path={let \p1=($(B)-(A)$),\n1={veclen(\x1,\y1)} in}, 
    sloped,] {\n1};
  \draw[red!90] (A) grid (B);
\end{tikzpicture}
\end{document}

enter image description here

Udi Fogiel
  • 3,824
lucky1928
  • 4,151
  • Use \pgfmathparse{\n1/1cm}\pgfmathresult cm instead of \n1 as node text. See: https://tex.stackexchange.com/a/99557/47927 – Jasper Habicht May 29 '23 at 22:41
  • Sorry, once again I have noticed my gold-badge powers too late ... If the linked answer does not answer your question, just let me know. – Jasper Habicht May 29 '23 at 22:46

0 Answers0