1

Could anyone explain what the commands

  • \@tempcntb

  • \count@\@ne

  • \@curtab

For reference, I found them on How to produce a list of prime numbers in LaTeX

i do understand that i can create new counts with

\catcode`\@=11 %makeatletter

\newcount@tempcntb \newcount@curtab

\catcode`@=12 %makeatother

but i don't see it appear in the macro, so i don't really understand them.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
needle
  • 913

2 Answers2

2

\@tempcntb is a scratch counter allocated by the LaTeX kernel, so it's always available.

It's similar for \count@, which uses \count255 and is historically a scratch register.

\@curtab is instead a counter used in the code for tabbing and should not be used otherwise. (Not a capital sin in the particular usage, but not good programming style nonetheless.)

The available scratch counters in LaTeX are

\count@
\@tempcnta
\@tempcntb
egreg
  • 1,121,712
  • tabbing is useless anyway so may as well use its counter for something:-) (although tabbing uses this globally but so long as you don't try to interleave a sieve calculation with laying out tabbing it's safe enough (although I admit a slightly odd choice I made at the time) – David Carlisle Feb 22 '21 at 11:21
1

You linked to the question but I assume you mean this code from my answer

\makeatletter
\def\primes#1#2{{%
  \def\comma{\def\comma{, }}%
  \count@\@ne\@tempcntb#2\relax\@curtab#1\relax
  \@primes}}
\def\@primes{\loop\advance\count@\@ne
\expandafter\ifx\csname p-\the\count@\endcsname\relax
\ifnum\@tempcntb<\count@\else
  \ifnum\count@<\@curtab\else\comma\the\count@\fi\fi\else\repeat
\@tempcnta\count@\loop\advance\@tempcnta\count@
\expandafter\let\csname p-\the\@tempcnta\endcsname\@ne
\ifnum\@tempcnta<\@tempcntb\repeat
\ifnum\@tempcntb>\count@\expandafter\@primes\fi}
\makeatother   

\@tempcntb and \@currtab are scratch count registers that are already defined by latex so you do not need \newcount (the first one intented for temporary use like this, the second one less so, it is normally used by tabbing

\count@\@ne is primitive syntax which sets the counter to 1.

David Carlisle
  • 757,742