7

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}
0

2 Answers 2

9

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

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .