\settowidth ¶Synopsis:
\settowidth{\len}{text}
Set the length \len to the width of the box that LaTeX gets on
typesetting the text argument.  The length name \len
has to be a control sequence (see Control sequence, control word and control symbol), and as such
must begin with a backslash, \ under normal circumstances.
This prints the width of the lowercase ASCII alphabet.
\newlength{\alphabetwidth}
\settowidth{\alphabetwidth}{abcdefghijklmnopqrstuvwxyz}
\the\alphabetwidth
If no such length \len has been declared with \newlength,
if for example you mistype the above as
\settowidth{\aplhabetwidth}{abc...}, then you get something
like ‘Undefined control sequence. <argument> \aplhabetwidth’.  If
you leave the backslash out of \len, as in
\settoheight{alphabetwidth}{...} then you get something like
‘Missing number, treated as zero. <to be read again> \setbox’.