Possible Duplicate:
Get width of a given text as length
In an attempt to Compute the x distance between two nodes, the question arose whether it is at all possible to devise A macro that expands to the length of its argument, or to any length. (The actual value or the way of obtaining it is irrelevant here.) Would it be necessary to generate a decimal representation of the length and parse it? How and why does the \widthof macro referred to in the linked question work?
\documentclass{article}
\pagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newcommand{\footextwidth}[1]{%
% Should expand to the natural width of the argument
1cm
}
\begin{document}
A test for the macro.
A \parbox{\footextwidth{test}}{~} for the macro.
\end{document}

\newcommand{\footextwidth}[1]{\setbox0=\hbox{#1}\the\wd0}– Marco Daniel Jul 19 '12 at 18:04\setlengthapproach used below. While doing an assignment anyway, you can as well assign a box inbetween, which is what\widthofdoes. – Stephan Lehmke Jul 19 '12 at 18:22\setlengthtrick is more or less the only solution. – Stephan Lehmke Jul 19 '12 at 18:46\footextwidthin the MWE is a macro which expands to a length. You really must say precisely what you are asking in this question. – Stephan Lehmke Jul 20 '12 at 05:00