I am dogmatic, and I believe that 0 is the very zerost number. Naturally, I would like all my counters to start at 0. Page counters, section counters, subsection counters, theorems, definitions -- everything! -- if it counts, it starts at 0.

I know how I can make a section counter start at 0: Getting section numbering to start at 0

But how do I efficiently satisfy my dogma without having to write many \setcounter{<...>}?

  • 1
    By default, a \newcounter command initalizes any counter with 0. The package totcount does initialize total counters however with -1. If somebody did not make errors in the class/package setup, this should not be a real issue. If there's a proper \newcounter{foo}[bar] statement, the counters on the reset list are set to zero as soon as the driver counter is increased with \stepcounter or \refstepcounter. – user31729 Aug 17 '16 at 21:19
  • 4
    You are wrong, I believe. The page number is zero until you look at the first page, which of course has page number 1. – egreg Aug 17 '16 at 21:20
  • @ChristianHupfer I am having a bit of trouble understanding your comment. The totcount package initializes total counters with -1, and if I understand correctly, the "total counters" are an addition of that package to count up the number of items of a thing? If yes, then what is the relevance/connection of total counters to counters, especially given the original question? – user89 Aug 17 '16 at 21:26
  • @user89: Just in case you're using the totcount package. – user31729 Aug 17 '16 at 21:29
  • The page counter starts at -1 because I set it to the list explicitly. – user31729 Aug 18 '16 at 8:03

enter image description here

\def\@Roman#1{\expandafter\@slowromancap\romannumeral\numexpr(#1)-1\relax @}





  • What is this arcane magic? It works with page numbers too! It works with figures! It works with amsmath and amsthm things! – user89 Aug 18 '16 at 15:51
  • 1
    @user89 you said you wanted it to apply to all counters. (it just changes the counter print commands so a counter prints as one less than its value. ) – David Carlisle Aug 18 '16 at 15:53
  • David, yeah, it does exactly what I wanted :) – user89 Aug 18 '16 at 15:53

You can use \LoopResetCounters from xassoccnt which sets all counters given in the comma-separated list to zero.

See the update for grabbing all counters defined with \newcounter and put them on a list at the end of this answer!










I've grabbed the comment by David Carlisle and exploited the \cl@@ckpt list in order to reset the all counters to -1, but omitted the page counter there!

In order to make the resetting list work, the \@stpelt list must be changed at all.

No additional package is needed at all!

This procedure does not influence the secnumdepth and tocdepth counters since those are not defined with \newcount.



    \ifx\@tmp@@a\@tmp@@b % Check if it is the page counter
  \cl@@ckpt% Loop through the list of all counters defined with \newcounter
  \gdef\@@resetvalue{#1}% Store the reset value

% Redefine the reset stepper \@elt - list marker

  \global\csname c@#1\endcsname \numexpr\@@resetvalue-1\stepcounter{#1}






\subsection{Foostuff subsection}
\subsubsection{Foostuff subsubsection}
\paragraph{Foostuff paragraph}
\subparagraph{Foostuff subparagraph}

\subsection{Foobar subsection}
\subsubsection{Foobar subsubsection}
\paragraph{Foobar paragraph}
\subparagraph{Foobar subparagraph}


\subsection{Barstuff subsection}
\subsubsection{Barstuff subsubsection}
\paragraph{Barstuff paragraph}
\subparagraph{Barstuff subparagraph}


enter image description here

  • I would have to populate the comma separated list manually though? – user89 Aug 17 '16 at 21:17
  • @user89: Yes, at the current state of the package. I did explicitly no changes to the \newcounter command (I am the author of xassoccnt by the way) – user31729 Aug 17 '16 at 21:20
  • I noticed you're the author (I looked up the package)! Is there no way to change the default value at which counters are initialized to -1? – user89 Aug 17 '16 at 21:29
  • 1
    @user89: Either use \LoopSetCounter{foo,foobar,section}{-1} or change the 0 in my second answer! – user31729 Aug 17 '16 at 21:33
  • 2
    latex already has a list of all defined counters, you don't need to redefine \newcounter to grab that see \show\cl@@ckpt – David Carlisle Aug 17 '16 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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