I have set the counter of chapters to 0 and now my table of contents is not working good. Is there any problem in setting that counter back to 0?
Before I had:
Part 1
Chapter 1
Chapter 2
Part 2
Chapter 3
Chapter 4
Chapter 5
And now I have:
Part 1
Chapter 1
Chapter 2
Part 2
Chapter 1
Chapter 2
Chapter 3
Still, when I click in the table of contents to chapter 2 in part 2 it sends me to chapter 2 in part 1.
I suppose you want to tie the chapter counter to the respective part. If I am correct with this assumption, then you may be interested in the use of the \counterwithin command in your preamble.
A note on this command: In more recent TeX distributions the command is supported without having to load another package. You can read more in issue 28 of ltnews.
In the general table of contents when you click on chapter two of part two (for example) it goes to chapter two of part one (and the same with all the parts).
Numbered chapters below not numbered parts are always problematic. Resetting the chapter number with the part makes this problem even much more serious. hyperref uses the number to generate the link anchor. So, if there is no part number and but several chapters with the same number, the link anchors for these chapters are the same. Using a KOMA-Script class there would be a workaround for this, by emulating not numbered parts with numbered parts:
However, you will still have the problem to reference, because if you say "see chapter 2" nobody will know, which chapter 2 you mean. And because the parts do not have a number, you cannot say "see chapter 2 in part 2", you always have to use the title of the part. So I would not recommend to combine resetting chapter numbers with ever part and not numbered parts:
Thank you very much for your kind expanation Ijon. Since I am using class scrbook, I have tried to do it emulating not numbered parts with numbered parts (makes sense).
However I am having still troubles with the toc hiperlinks:
*EDITED: see next message*
I have commented de chapter counter resettings and the \addcontentsline, since I am using now parts instead of parts*. However, when I click on the TOC on chapter two of part two its still driving me to chapter 2 in part 1.
Also, I'm not getting the difference between \counterwithin and \counterwithin* but I have written it as you did in your message just in case.
Last edited by javgarmar on Thu Oct 01, 2020 1:43 pm, edited 1 time in total.
The link to the chapter in the firstpart goes to the chapter in the second part (page 7).
The link to the chapter in the second part goes to the chapter in the second part (page 13).
Do you really get another result with my code? Are you sure, you are using an up-to-date LaTeX, i. e. the current versions of KOMA-Script and hyperref?
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms.
I am using overleaf currently but I usually also use winedt when I am offline.
The thing is that with your code, what I get is two parts with one chapter each. Howerver, it is true that in this case the toc its working, when I click on chapter one part 2 it doesn't go to the one in part 1.