[texhax] Howto Count tokens

Tim Dijkstra newsuser at famdijkstra.org
Wed Sep 19 11:53:15 CEST 2007

Dr. R. Hasson schreef:
> Dr. T.P.T. Dijkstra wrote:

>> I have a register created with \newtoks\list, it's content is roughly
>> 	{AA \mysep{BB \mysep CC \mysep DD} \mysep{EE} }
>> 	\def\mysep#1{\advance\mycount1\relax #1}\the\list
>> Now I get the correct number, but now it also outputs AA BB CC DD EE.
>> In other words I need a way to expand the list but discard the output,
>> I only need the `by product'.
> Why not put the output in a box (and then forget about it)? For example:
> \def\mysep#1{\global\advance\mycount1#1}\setbox0\hbox{\the\list}
> (The global is needed to advance the counter despite the nesting.)

Ah, thank you! This is precisely what I needed.

Grts Tim

More information about the texhax mailing list