# Resetting newtheorem counter

This one is probably straightforward, but I'm not missing something with the newtheorem environment and using newcounter. I would like a new environment on its own counter like "Environment M.1", but I get "Environment M.0.1" in the following.

\documentclass{article}

\newcounter{mycounter}
\renewcommand{\themycounter}{M.\arabic{mycounter}}
\newtheorem{myenv}{Environment}[mycounter]

\begin{document}

\begin{myenv}[Some Stuff]
\end{myenv}

\end{document}

-

You don't need to define a new counter -- \newtheorem{myenv} already creates the necessary counter myenv. Just redefine \themyenv.

\documentclass{article}

\newtheorem{myenv}{Environment}
\renewcommand*{\themyenv}{M.\arabic{myenv}}

\begin{document}

\begin{myenv}[Some Stuff]
\end{myenv}

\end{document}

-
Perfect. And right when you posted that I found this –  walleye Aug 3 '11 at 14:51
@walleye: Indeed -- your question may not be an exact duplicate, but Martin's answer also covers your question. –  lockstep Aug 3 '11 at 14:56
@walleye: BTW, you provided a good minimal example! –  lockstep Aug 3 '11 at 15:02
To clarify, this is a newtheorem thing? Not every newenvironment defines a counter, right? –  Seamus Aug 3 '11 at 15:40
@Seamus: As far as I know, right. –  lockstep Aug 3 '11 at 15:59

Some explanation what went wrong: \newtheorem{myenv}{Environment}[mycounter] tells LaTeX to number the theorem environment myenv “within” mycounter. This means that \themyenv is set to \themycounter.\arabic{myenv} and the myenv counter is reset whenever mycounter is incremented. The typical use of this is to number within sections or chapters. On the other hand, \newtheorem{myenv}[mycounter]{mycounter} tells LaTeX to use mycounter to number myenv.

-