TransWikia.com

what do these commands do

TeX - LaTeX Asked on May 20, 2021

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.

2 Answers

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

makeatletter
defprimes#1#2{{%
  defcomma{defcomma{, }}%
  count@@ne@tempcntb#2relax@curtab#1relax
  @primes}}
def@primes{loopadvancecount@@ne
expandafterifxcsname p-thecount@endcsnamerelax
ifnum@tempcntb<count@else
  ifnumcount@<@curtabelsecommathecount@fifielserepeat
@tempcntacount@loopadvance@tempcntacount@
expandafterletcsname p-the@tempcntaendcsname@ne
ifnum@tempcnta<@tempcntbrepeat
ifnum@tempcntb>count@expandafter@primesfi}
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.

Correct answer by David Carlisle on May 20, 2021

@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

Answered by egreg on May 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP