\settowidth

\settowidth{\gnat}{text}

The \settowidth command sets the value of a length command equal to the width of the text argument.

See also: Lengths,