[Tex/LaTex] Increment custom counter with standard sectioning command


My document is a (scr)book and I'm talking of parts and chapters here, but I think the underlying question is pretty generic.

  • I want tables in the book to be enumerated continuously, in a chapter.table way.

  • I reset the chapter counter for each part of the book using a custom-made MyPart command, which is necessary for several other reasons not presented here.

  • However, I do not want to reset the table numbering. (I.e., the "chapter" part in the table number should keep a running total of chapters across part boundaries.)

I got it working by defining a counter tabchapter, and bumping that one manually whenever a new \chapter is declared. I wanted to avoid having to declare something like \MyChapter solely for this purpose, but I was not satisfied with my solution:



\renewcommand*{\tableformat}{Tab. \thetable}

%% Ugly hijacking of a formatting command to follow...
    {\addtocounter{tabchapter}{1}\Huge\bfseries}   %% <<----  *COUGH*...


            Nothing much.

\MyPart{Book One}
\chapter{The First}
\exampletable{Some Table}
\chapter{The Second}
\exampletable{Other Table}
\MyPart{Book Two}
\chapter{The First of the Second}
\exampletable{Yet Another Table}

Is there another way to have some counter incremented whenever a standard sectioning command is called (i.e., somehow "linking" it to the standard counter)? Other than wrapping the bump in a custom \MyChapter command?

Best Answer

No need of titlesec

\renewcommand*{\tableformat}{Tab. \thetable}
Related Question