Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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