yihui / bookdown-crc

A minimal example of using bookdown to write a book for Chapman & Hall/CRC
https://yihui.name/en/2018/08/bookdown-crc/
MIT License
72 stars 66 forks source link

Unnumbered chapters appear twice in TOC #7

Open turtlegraphics opened 3 years ago

turtlegraphics commented 3 years ago

This is an issue with the krantz.cls file, but since this repo is the best source for making a CRC krantz.cls book, I thought I should raise it here.

Unlike a latex book, krantz.cls by default includes unnumbered chapters in the TOC. As far as I can tell, this is unaffected by being part of \frontmatter or \mainmatter.

The problem does not appear in this demonstration book because the _output.yml file has the code toc_unnumbered: false to suppress the duplicate headings. You'll notice that in this demo book, the Preface does appear in the TOC. However, there are other reasons one might want toc_unnumbered: true (say, for unnumbered sections to appear).

My suggested solution is to comment out, or remove, line 717 of krantz.cls which has \addcontentsline{toc}{fm}{#1} in the definition of \@schapter. That will make krantz.cls behave more like the normal latex book class and requires unnumbered chapters to be explicitly included in the TOC. Since bookdown handles the TOC for unnumbered chapters and sections, this makes krantz.cls behave better with bookdown.

If there's a better approach I'd love to hear it, or if this seems like the right fix then it would be helpful to change it in this repo.