latexCounters, if statements and loops with latex