I'm trying to use this answer to extract the coordinates of a point without the pt. But why is the following not working? The first \JustNumber works as exected, but the second not, although \show\X gives > \X=macro:->0.0pt..
\documentclass{article}
\usepackage{tikz}
\def\JustNumber#1pt{#1}
\begin{document}
\JustNumber0.0pt.
\begin{tikzpicture}
\path (0,0);
\pgfgetlastxy{\X}{\Y}
\show\X
\xdef\X{\expandafter\JustNumber\X}
\end{tikzpicture}
\end{document}
Why do I want this? I want to fill the rectangle between two points with a dotted grid. Because patterns seem to cause various problems when it comes to precise positioning, I thought of extracting the coordinates (without the pt) and feeding them into a \foreach.
\pgfmathsetmacro{\ValueWithoutUnit}{\ValueInPt}to achieve this. You can also convert into cm in one go:\pgfmathsetmacro{\ValueWithoutUnit}{\ValueInPt / 1cm}– Jasper Habicht Mar 07 '24 at 10:54