6

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}
8

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.

  • Thank you for your comment! In TeX I have no one looking over my shoulder, it is only the printout or pdf that counts. But usually I put \parindent=0pt at the very beginning, and then I make indents with \quad, or some macro of variable size. Then I get the page to look like I want it. In LaTeX I noted the irritating indents, and the \noindent command is the only way I know of, how to avoid it. – user35145 Nov 9 '14 at 22:51
  • 2
    @user35145 \def\ss3 defines the command \ss (which is the German s-z ligature) so that it has to be followed by a 3 and then adds a space. Do you really intend that? – David Carlisle Nov 9 '14 at 23:13
  • 2
    @user35145 \def\ss1{.} \def\ss2{..}` all (re)define the same command, \ss so I don't know what you mean by "I would also have ss1, ss2, etc." and I explicitly mentioned \thec7 does not work in my answer, so you should use counter names using letters. – David Carlisle Nov 9 '14 at 23:43
  • 2
    @user35145 the site isn't really set up for discussion (it will start giving automated complaints about the length of this thread soon) but apart from naming issues, if you are adding explicit spacing routinely into your document then something is very wrong. without seeing an example (in another question) I can't really say more than that. – David Carlisle Nov 10 '14 at 0:11
  • 2
    @user35145 look is important but also how you use markup to achieve that look. Using latex correctly doesn't mean accepting lower quality output. – David Carlisle Nov 10 '14 at 0:22

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.