LaTeX forum ⇒ MakeIndex, Nomenclature, Glossaries and AcronymsProblem with TOC Topic is solved

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
Jongomez
Posts: 28
Joined: Tue Nov 28, 2023 9:29 pm

Problem with TOC

Postby Jongomez » Wed Dec 20, 2023 2:46 pm

Good morning,
At the end of my Overleaf Latex document I have the following coding lines:

\markright{\MakeUppercase{Bibliografía}}
\include{sections.tex/Bibliografía}

\addcontentsline{toc}{chapter}{Bibliografía}
\clearpage

\markright{\MakeUppercase{Índice de términos}}
\index{Índice de términos}
\addcontentsline{toc}{chapter}{Índice de términos}


\clearpage
\index{Índice de nombres}
\addcontentsline{toc}{chapter}{Índice de nombres}
\markright{\MakeUppercase{Índice de nombres}}

\printindex


PROBLEM: On the TOC: when clicking either entry: "Índice de términos" or "Índice de nombres" it sends me to "Bibliografía", instead to the right entry.

Can anyone help me on this problem?

Thanks a lot
Last edited by Stefan Kottwitz on Wed Dec 20, 2023 3:20 pm, edited 1 time in total.
Reason: code marked

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
Stefan Kottwitz
Site Admin
Posts: 10122
Joined: Mon Mar 10, 2008 9:44 pm

Problem with TOC

Postby Stefan Kottwitz » Wed Dec 20, 2023 3:19 pm

Hi Jon,

put the \phantomsection command immediately before the \addcontentsline command, to create an anchor for the hyperref link.

Stefan

PS: it would be great if you would use the "Code" button when writing code in a post, instead of "**************************************************************************" before and after. Code is automatically highlighted and works with the online compiler here in the forum, which is especially beneficial for small compilable examples. I did it for you above.
LaTeX.org admin

Jongomez
Posts: 28
Joined: Tue Nov 28, 2023 9:29 pm

Problem with TOC

Postby Jongomez » Wed Dec 20, 2023 6:48 pm

Hi Stefan,
You are great! It is very grateful to work with persons like you.
Your proposal has worked with "Índice de términos", but clicking on "Índice de nombres" on TOC entries it sends mi to "Índice de términos". What can be the cause?

Note.- I think I did something wrong with the code button: I've highlited the code lines below, but I haven't got the appropriate result. Would you let me know where is my error?
Thansk a lot.


\markright{\MakeUppercase{Índice de términos}}
\index{Índice de términos}
\phantomsection
\addcontentsline{toc}{chapter}{Índice de términos}

\markright{\MakeUppercase{Índice de nombres}}
\index{Índice de nombres}
\phantomsection
\addcontentsline{toc}{chapter}{Índice de nombres}

Jongomez
Posts: 28
Joined: Tue Nov 28, 2023 9:29 pm

Problem with TOC

Postby Jongomez » Wed Dec 20, 2023 7:05 pm

Sorry Steffan, I've realised that the code button works properly.
I hope you can help me with my last question.

Bet regards,
Jon

Jongomez
Posts: 28
Joined: Tue Nov 28, 2023 9:29 pm

Problem with TOC  Topic is solved

Postby Jongomez » Wed Dec 20, 2023 8:20 pm

Hi Steffan,
I think I got it finally.

This is the coding that works ok:

\markright{\MakeUppercase{Índice de términos}}

\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Índice de términos}
\index{Índice de términos}
\printindex

\cleardoublepage
\phantomsection

\addcontentsline{toc}{chapter}{Índice de nombres}
\markright{\MakeUppercase{Índice de nombres}}
\index{Índice de nombres}


Please let me know your opinion

Thanks so much for your help.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10122
Joined: Mon Mar 10, 2008 9:44 pm

Problem with TOC

Postby Stefan Kottwitz » Wed Dec 20, 2023 9:00 pm

Looks good! Specifically, the \cleardoublepage before both \phantomsection and the next chapter so you ensure that the anchor is on the new chapter's first page. Otherwise, the anchor would be on the current page, then you start a chapter that begins on another page, so the anchor/link would be wrong.

Stefan
LaTeX.org admin

Jongomez
Posts: 28
Joined: Tue Nov 28, 2023 9:29 pm

Problem with TOC

Postby Jongomez » Thu Dec 21, 2023 2:05 pm

Hi Steffan,
It is always a pleasure hearing your opinions and recommendations.

thanks again,
Jon


Return to “MakeIndex, Nomenclature, Glossaries and Acronyms”

Who is online

Users browsing this forum: No registered users and 1 guest