Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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]
Here are some comments.
\end{myenv}

\end{document}
share|improve this question
add comment

2 Answers

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]
Here are some comments.
\end{myenv}

\end{document}
share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.