4
\documentclass{minimal}
\parindent=0sp

\newlength{\Length}
\setlength{\Length}{1in}

\newcounter{Count}
\setcounter{Count}{10}


\begin{document}
\the\Length

\theCount
\end{document}

Length needs backslash but counter does not, why?

6

Counter names are used for many purposes and it's safer to just append the name to the or c@ or p@ and to use it as the argument of \arabic, \Roman and so on. When you say \newcounter{Count}, LaTeX does, among other things

\expandafter\newcount\csname c@Count\endcsname
\@namedef{theCount}{\arabic{Count}}

Moreover this makes more complicated to do local assignments to counters, that should never be done, because LaTeX counters should always be modified globally; for local counters there are the "TeX" counters that can be defined by \newcount; in general, however, \count@, \@tempcnta and \@tempcntb provided to this purpose by the LaTeX kernel suffice. See this discussion on TeX.sx to know more about doing local and global assignments to the same variable, which shows that my statement before is quite drastic, but one should know what they are doing when "violating" rules.

For lengths this is not needed and one can even use TeX syntax

\Length=3cm

(assuming all the connected risks). Moreover, and probably more important, \setlength and \addtolength are easier to define and use.

  • 2
    while all that martin says is true, there's a bit of "because it is" in the answer to this question, imo. if lamport had chosen to treat skips the same as counts, no-one (surely) would have minded -- excepting, of course, those who despise latex's principles, root and branch. – wasteofspace Jul 17 '11 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.