[NTG-context] xtable row number trouble

Wolfgang Schuster wolfgang.schuster.lists at gmail.com
Mon Oct 26 22:42:47 CET 2020


Oleg schrieb am 26.10.2020 um 21:03:
> On Sun, Oct 25, 2020 at 09:26:06PM +0100, Wolfgang Schuster wrote:
>> Oleg schrieb am 25.10.2020 um 14:51:
>>> Hi, all.
>>>
>>> I try to place a row number into the first column of my table.
>>> I tried:
>>>
>>> \definecounter[rownum][way=bytext,prefix=no]
>>> \setcounter[rownum][0]
>>>
>>> \starttext
>>> \startxtable
>>>       \startxrow
>>>           \startxcell
>>>               \incrementcounter[rownum]
>>>               \rawcounter[rownum]
>>>           \stopxcell
>>>       \stopxrow
>>>       \startxrow
>>>           \startxcell
>>>               \incrementcounter[rownum]
>>>               \rawcounter[rownum]
>>>           \stopxcell
>>>       \stopxrow
>>>       \startxrow
>>>           \startxcell
>>>               \incrementcounter[rownum]
>>>               \rawcounter[rownum]
>>>           \stopxcell
>>>       \stopxrow
>>> \stopxtable
>>>
>>> And got:
>>>
>>> 7
>>> 8
>>> 9
>>>
>>> If i place \setcounter[rownum][0] right after \startxtable, then i got:
>>>
>>> 1
>>> 2
>>> 3
>>>
>>> Is this normal?
>> Yes, to fix it use
>>
>> \startxcell
>>     \doifelsemode{*trialtypesetting}
>>       {0}
>>       {\incrementcounter[rownum]%
>>        \convertedcounter[rownum]}
>> \stopxcell
> It seems that reseting once at table start is simpler, isn't it :-)?

Try your method with natural table or tabulate and it won't work anymore.

> What is the difference between \rawcounter and \convertedcounter?
> \rawcounter give me the plain number as i want.

In this case there is no difference but I suggest to use \rawcounter 
only when you need
the value of the counter, e.g. counter>... or counter=...

With \convertedcounter you have always the option to change the style of 
the value,
e.g. number conversion, prefixes etc.

> What's about \newcount&\advance variant? Why it not work?

Short answer: expansion

You're using advance in a place where it is just ignored, there are ways 
to get rid
of these limitations with Luametatex but it's better to use 
\incrementcounter.

Wolfgang



More information about the ntg-context mailing list