[Tex/LaTex] Correct usage of the LaTeX \newcounter and associated commands

countersmacros

Previously I had a question about the \newcount command. I was then led to consider the \newcounter command instead, that does allow the use of digits in counter names. Accordingly, I have modified the MWE I submitted with the previous question. My present question is wheter the usage exemplified in the attached MWE is in accordance with correct, or recommended usage within the LaTeX framework ? Here is the MWE :

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  Example LaTeX-file that illustrates the use     %%
%%  of \newcounter and associated commands          %%
%%                                                  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%         

\documentclass{article}
\usepackage[paperwidth=0.75in, paperheight=1in]{geometry}
\pagestyle{empty}

\begin{document}

\newcounter{a}  \newcounter{b} \newcounter{c7}

\setcounter{a}{1}   \setcounter{b}{41} \setcounter{c7}{78}

\noindent
a = \number\value{a} 
\par \vskip 5pt \noindent
b = \number\value{b}  
\par \vskip 5pt \noindent 
c7 = \number\value{c7} 

\end{document}

Best Answer

It is sort of legal latex but clearly not "good latex style". \noindent shouldn't normaly be used, and \vskip shouldn't be used. (\vspace) Normally within a document one would use a blank line rather than \par (\par is more use within macro definitions where a blank line often looks less convenient, as you may wish to indent code).

LaTeX counters like a have a print representation command \thea which should be used to print the value. The document sets this up so that if the value is 2 it may print as 2 or 3.1.2 or a or ii depending on the style specified. \value{a} returns the underlying number in the register. \number\value{a} prints the decimal value of that value but is almost never used.

Note also that c7 while a latex counter in some sense is inconvenient as the print command thec7 is not accessible as \thec7 so you would have to use \csname thec7\endcsname but really there is no advantage in using non-letters in the counter name.