# Personal counter is unintended reset after itemize environment [duplicate]

I created a counter named foo to add up so money which I want to get from my boss. When having an itemize environment the counter is reset accidently. Does anyone know why or how to solve problem (so tell my what I am doing wrong ;-) )? I added comment lines to clear up what I want to do. Everytime I add a value of money, the sum is created.

\documentclass{scrbook}
%\usepackage{eurosym}
\begin{document}
Create Counter: \newcount\foo

Give counter: \the\foo

Increase by three: \advance\foo by 3

Give result: \the\foo

\begin{itemize}
\item Increase by seven: \advance\foo by 7
%\item \eu{7}
\item Give result: \the\foo
\end{itemize}

Give result: \the\foo
\end{document}


The PDF looks like:

Create Counter:

Give counter: 0

Increase by three:

Give result: 3

• Increase by seven:

• Give result: 10

Give result: 3

I use texniccenter with Miktex 2.9 on a Win7 64 machine.

## marked as duplicate by yo', user13907, Jesse, Mensch, Martin SchröderAug 19 '14 at 10:33

• tex.stackexchange.com/questions/35084/… might help here: you are using a 'raw' TeX count register rather than the LaTeX wrapper as a counter, and you therefore have to allow for grouping. – Joseph Wright Aug 19 '14 at 7:50
• Any environment is a single group. So everything you are doing inside this group is local. Using some values outside a group you have to work with \global. Using expl3 gives you some more options. – Marco Daniel Aug 19 '14 at 7:52

These are TeX-core counters, which work locally. You would have to use \global\advance. However, I suggest using LaTeX counters, which are global by default:

\documentclass{scrbook}

\begin{document}
Create Counter: \newcounter{foo}

Give counter: \arabic{foo}