1

I'm using a template my college provided to write my thesis in Latex, and i'm having a minor issue with autoref adding unwanted chapters to the TOC (index), the relevant bit are as such I believe

The code can be seen here:

sty page

main page

chapter to be included in TOC

chapter not to be included in TOC

I tried following this link from stackoverflow, and this post, but I can't seem to figure out the problem, specially because it only started appearing after I used the package hyperref to include the labels in chapters. I know that by doing \chapter*{}, however that does not seem to work since I included hyperref

The index appears like this:

index appear like this

But I don't want the unnumbered entries to appear (I mean Resumo, abstract, Indice, Lista de Tabelas and Lista de Figuras)

2
  • Please don't post links to code. Instead, make a complete sample document that shows the problem and include it in your question. In this case the sample document should include only \documentclass{...}\usepackage{hyperref}\begin{document}\tableofcontents\chapter{DummyChapter}\end{document} and any packages you are using that specifically affect the chapter formatting. The template itself (either a package or class) can be linked if needed.
    – Alan Munn
    Aug 13, 2021 at 23:25
  • But looking at the code, the custom style explicitly creates a command for chapters included in the contents, and the \myPrefaceChapter command uses that and the various \myTableofContents commands also use a similar command.
    – Alan Munn
    Aug 13, 2021 at 23:34

1 Answer 1

1

After reading the sty file your school provided, I found the following lines:

\newcommand{\myTocXX}[2]
   {
   \chapter*{#1\@mkboth{Conteúdo}{CONTENTS}}
   \addcontentsline{toc}{chapter}{#1}
   \@starttoc{#2}
   }

\newcommand{\myTableOfContents}
   { \myTocXX{Índice}{toc} }

So I guess your college really wants the unnumbered chapters to be in the TOC since they especially put it in the .sty. So I wouldn't recommend you to change it but anyway.

By redefining the \myTocXX macro, you can achieve what you want, you just have to put the following lines before begin{document}:

\makeatletter
\renewcommand{\myTocXX}[2]
   {
   \chapter*{#1\@mkboth{Conteúdo}{CONTENTS}}
   \@starttoc{#2}
   }
\makeatother

And here's my output:

My LaTeX output for the answer

2
  • +1 you'll also need to change the \noNumChapterInIndex command for other unnumbered chapters.
    – Alan Munn
    Aug 13, 2021 at 23:35
  • @AlanMunn I don't get why is \noNumChapterInIndex defined since it's just called in \myPrefaceChapter definition which is never used elsewhere...
    – Enevevet
    Aug 13, 2021 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .