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.

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

share|improve this question
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 '11 at 18:34

1 Answer 1

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.

share|improve this answer
    
Thank you very very much! It was the command \setcounter, that I was lacking. It helped a lot! –  kika Nov 29 '11 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. –  Ulrich Schwarz Nov 29 '11 at 21:37
    
Works also for lists \setcounter{enumi}{-1}. Thanks! –  lony Nov 12 at 5:51

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.