TLDR; Is there a way I can use the final value of a variable at the beginning of a document?
I want to automatically generate a report by simply adding textblocks. Every textblock-occurence increases the according counter, which works pretty fine. For example, [cat, dog, bird] textblocks can be created. The variables cnt_dog, cnt_cat, cnt_bird are defined in advance and are increased by using \newcommand{\catbox}{\addtocounter{cnt_cat}{1}}.
Now the problem: When I access the variable (\arabic{cnt_cat}) at the end of the document (using TeX-Studio) everything works fine, but when I access the variable at the beginning of the document, the value is 0. Seems the parser does not update the previously used value in the end :/
Cheers, Andi