0

I'm having an issue getting the caption numbering to restart per chapter. For background, to follow guidelines of the publisher, algorithms get forced into something called an "object," which behaves like a figure- labelled by chapter followed by the number it is within the chapter and pulled into the List of Objects (e.g. Object 2-1.). For some reason, the objects are not renumbering at the start of a new chapter, so it looks like Object 2-1, Object 4-2, 4-3, etc. Tables and figures restart with no issue. Is there a way to override the caption to number properly, or to get LaTeX to notice the list should not continue through chapters?

To force algorithms into objects, we have \floatname{algorithm}{Object} and then set the algorithm list to be changed to List of Objects:

\let\listofObjects\listoftables   %  Copy command
\patchcmd{\listofObjects}{\listtablename}{\listalgorithmname}{}{} %Patch the three instances of \listtablename
\patchcmd{\listofObjects}{\listtablename}{\listalgorithmname}{}{}% to all be converted to the
\patchcmd{\listofObjects}{\listtablename}{\listalgorithmname}{}{}% \listalgorithmname.
\patchcmd{\listofObjects}{lot}{loa}{}{}

Right now, we have the following set to make the label chapternumber-numberinchapter: \renewcommand*{\thealgorithm}{\thechapter-\arabic{algorithm}} We have this set for other elements with no issue (table, equation, figure, etc, ex. \renewcommand*{\thefigure}{\thechapter-\arabic{figure}} works fine). It also seems that if I remove the \floatname{algorithm}{Object}, they algorithms just change to Algorithm 2-2, so the number is still incorrect. I'm not sure where to use \newcounter instead

This template certainly needs some updating, but unfortunately the person who created it is no longer here, so I apologize if I've explained anything poorly.

TnDMeg
  • 1
  • 4
    You need to set \counterwithin for this new object type, see https://texfaq.org/FAQ-addtoreset for some explanation. Without some code for your documentclass or document it is difficult to give a more precise answer, if you add some code to your question then we can advise exactly which changes to make and where. – Marijn Nov 09 '22 at 14:35

1 Answers1

0

just wanted to put this out there if anyone has a similar issue. At the beginning of each chapter, I just used \counterwithin{algorithm}{chapter}which was good for getting the numbering correct, and followed it with \renewcommand*{\thealgorithm}{\thechapter-\arabic{algorithm}} again to get it to format with the dash instead of the period. Thank you for your help.

TnDMeg
  • 1
  • That seems to be only necessary at the start of the document, not with every chapter. Would you agree? – Werner Nov 15 '22 at 21:10