Se non ho capito male, il problema e' un po' piu' complesso.
Vedi se questo ti può aiutare.

http://www.w3.org/TR/CSS21/generate.html#counters