# What is the difference between \def and \newlength?

I wrote the following LaTeX documents.

\documentclass[11pt]{book}

\newlength{\mywidth}
\newlength{\myheight}
\setlength{\mywidth}{85mm}
\setlength{\myheight}{112mm}

\newcommand{\setpagesize}[2]{%
\special{papersize=#1,#2}%
}

\setpagesize{\mywidth}{\myheight}

\begin{document}
The quick brown fox jumps over the lazy dog
\end{document}

I got following error messages from dvipdfmxand failed.

$latex abc.tex$ dvipdfmx abc.dvi
abc.dvi -> abc.pdf

** WARNING ** Reading special command failed: "papersize=\mywidth ,\myheight "
[1
** WARNING ** Reading special command failed: "papersize=\mywidth ,\myheight "
]
4327 bytes written

When I use \def in place of \newlength and \setlength, it worked.

\documentclass[11pt]{book}

\def\mywidth{85mm}
\def\myheight{112mm}

\newcommand{\setpagesize}[2]{%
\special{papersize=#1,#2}%
}
% ...

$latex abc.tex$ dvipdfmx abc.dvi
abc.dvi -> abc.pdf
[1]
4331 bytes written

Why?

-
I can't reproduce that with my version of dvipdfmx. Perhaps try changing \setpagesize{\mywidth}{\myheight} to \setpagesize{\the\mywidth}{\the\myheight}? –  Bruno Le Floch Apr 13 '11 at 14:50
@Bruno: I didn't get an error too, but I didn't get a sensible pagesize either. \the is certainly needed. –  Ulrike Fischer Apr 13 '11 at 15:30
Thank you for your response. My version of dvipdfmx is "dvipdfmx-20110311 by the DVIPDFMx project team, an extended version of dvipdfm-0.13.2c developed by Mark A. Wicks". –  SAEKI Yoshiyasu Apr 13 '11 at 21:45
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). –  Martin Scharrer May 12 '11 at 0:15