4

I defined a \newtheoremstyle and I want it to start counting at 0 instead of 1. How do I do that?

1
  • 6
    Welcome to TeX.SX! Your question is interesting, but you should add more information, for example the code for the new theorem style and the package you're using (ntheorem or amsthm).
    – egreg
    Nov 29, 2011 at 18:34

1 Answer 1

5

Both amsthm and ntheorem defines \newtheoremstyle to declare a new theorem style with each having very different interfaces. However, both define the counter associated with a new theorem environment in a similar way. In both instances, setting the counter to -1 after the declaration but before the first usage, or in the document preamble, initializes it to start at 0.

amsthm:

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{amsthm}% http://ctan.org/pkg/amsthm

\newtheoremstyle{lemmastyle}% <name>
  {3pt}% <Space above>
  {3pt}% <Space below>
  {}% <Body font>
  {}% <Indent amount>
  {\itshape}% <Theorem head font>
  {:}% <Punctuation after theorem head>
  {.5em}% <Space after theorem head>
  {}% <Theorem head spec (can be left empty, meaning `normal')>
\theoremstyle{lemmastyle}
\newtheorem{lemma}{Lemma} \setcounter{lemma}{-1}

\begin{document}
\lipsum[1]
\begin{lemma}
\lipsum[2]
\end{lemma}
\end{document}

ntheorem:

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{ntheorem}% http://ctan.org/pkg/ntheorem
\makeatletter
\newtheoremstyle{lemmastyle}%
  {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}% no optional argument
  {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)\theorem@separator]}% optional argument
\makeatother
\theoremstyle{lemmastyle}
\newtheorem{lemma}{Lemma} \setcounter{lemma}{-1}
\begin{document}
\lipsum[1]
\begin{lemma}
\lipsum[2]
\end{lemma}
\end{document}​

However, if your newly-defined theorem is synchronized with (a slave to) another counter (the master counter), like that of (say) \chapter or \section, then some more work needs to be done in order to reset it to -1 (rather than 0) at every master counter increment.

In both instances lipsum was used to provide dummy text Lorem ipsum style.

3
  • Thank you very very much! It was the command \setcounter, that I was lacking. It helped a lot!
    – kika
    Nov 29, 2011 at 21:33
  • @kika: if you find this answer best solves your problem, please don't forget accepting it as the correct answer by clicking the checkmark next to it. Nov 29, 2011 at 21:37
  • Works also for lists \setcounter{enumi}{-1}. Thanks!
    – lony
    Nov 12, 2014 at 5:51

You must log in to answer this question.

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