0

I'm new to latex and I'm trying to write my thesis

I'm having issues with the table of contents. When I call it, normally it works fine and I get entries for my chapters

what I get when I don't use hyperref or bookmark

but when I add the packages hyperref or bookmark (I uncomment them) the table of contents disappears (I'm left with a black page with just the title "Indice" which is the automatic title that appears on the table of contents page). This is my code:

\documentclass[12pt,a4paper]{report}
\usepackage[italian]{babel}
\usepackage{newlfont}
\usepackage{color}
\usepackage{graphicx}

\graphicspath{ {immagini/} } \textwidth=450pt\oddsidemargin=0pt

\usepackage{cite} %\usepackage{bookmark} %\usepackage{Hyperref}

\begin{document} \begin{titlepage} % % % UNA VOLTA FATTE LE DOVUTE MODIFICHE SOSTITUIRE "RED" CON "BLACK" NEI COMANDI \textcolor % % \begin{center} {{\Large{\textsc{Alma Mater Studiorum $\cdot$ Universit`a di Bologna}}}} \rule[0.1cm]{15.8cm}{0.1mm} \rule[0.5cm]{15.8cm}{0.6mm} \\vspace{3mm}

        {\small{\bf Scuola di Scienze \\ 
                Dipartimento di Fisica e Astronomia\\
                Corso di Laurea in Fisica}}

    \end{center}

    \vspace{23mm}

    \begin{center}{\LARGE{\bf TITOLO TESI}\\
    }\end{center}

    \vspace{50mm} \par \noindent

    \begin{minipage}[t]{0.47\textwidth}
        %
        % INSERIRE IL NOME DEL RELATORE CON IL RELATIVO TITOLO DI DOTTORE O PROFESSORE
        %
        {\large{\bf Relatore: \vspace{2mm}\\\textcolor{black}{
                    Prof./Dott. Nome Cognome}\\\\
                    \textcolor{black}{
                    \bf Correlatore: (eventuale)
                    \vspace{2mm}\\
                    Prof./Dott. Nome Cognome\\\\}}}
    \end{minipage}
    %
    \hfill
    %
    \begin{minipage}[t]{0.47\textwidth}\raggedleft \textcolor{black}{
            {\large{\bf Presentata da:
                    \vspace{2mm}\\
                    %
                    % INSERIRE IL NOME DEL CANDIDATO
                    %
                    Nome Cognome}}}
    \end{minipage}

    \vspace{40mm}

    \begin{center}
        %
        % INSERIRE L'ANNO ACCADEMICO
        %
        Anno Accademico \textcolor{black}{ 2021/2022}
    \end{center}

\end{titlepage}

\chapter*{Abstract} Abstract goes here

%\chapter*{Dedication} %To mum and dad

%\chapter*{Declaration} %I declare that..

%\chapter*{Acknowledgements} %I want to thank...

\tableofcontents

\chapter{Introduzione} \input{capitoli/introduzione}

\chapter{Modello Standard} \input{capitoli/sm}

\chapter{Analisi Dati} \input{capitoli/analisiDati}

\chapter{Chapter Four Title} \input{capitoli/capitolo03}

\chapter{Conclusion} \input{capitoli/conclusioni}

\appendix \chapter{Appendice} \input{capitoli/appendice}

\bibliographystyle{IEEEtran} \bibliography{./biblio}

\end{document}

what i get when i use hyperref or bookmark

I'm using TeXstudio 4.0.4

Thanks in advance

(images are what I get without those packages (1st) and with them (2nd))

EDIT

i forgot, adding these it works fine

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

Thanks to everyone!

gorsedh
  • 15
  • Welcome to TeX.SX! :) Three hints to improve your code: (1) the example is missing one or more lines at the beginning (it should begin with \documentclass), please include them. (2) The \input commands are a stumbling block for potential helpers, because we don't have the files "introduzione.tex" etc. and we get an error. It would help if you could remove them, and leave the commands \chapter, which are needed to create a TOC. (3) hyperref is written in lowercase (not "Hyperref") – marquinho Feb 21 '22 at 21:40
  • 1
    With \documentclass{book} I cannot reproduce your error, using either pkg bookmarks or hyperref, or both. – marquinho Feb 21 '22 at 21:42
  • Hi there i don't know how to reply to you but
    1. simon, i tried and it didn't work, thanks anyway :)
    2. marquinho, \documentclass was present but it copy from my file to this page. Also thanks for your precious advices.

    I solved the issue and edited the post. I don't know how to close the thread, maybe a mod can help me. Best regards

    (3) simon i tried with your code but it didn't work without the fontenc and inputenc

    – gorsedh Feb 21 '22 at 21:47
  • Try the code of my answer. – Simon Dispa Feb 21 '22 at 21:48
  • 1
    compile a second time. hyperref will suppress the toc the first time to avoid errors. – Ulrike Fischer Feb 21 '22 at 21:49
  • @gorsedh hyperrefchanges the way the toc is made behind the scenes. And it needs that you compile twice the same code. So, just try to run latex twice instead of once. Have also a look here: https://tex.stackexchange.com/questions/113006/which-package-should-i-load-first-hyperref-or-bookmark?rq=1 Possibly it's not needed to load bookmarks – Iacobus1983 Feb 21 '22 at 21:50
  • do you know how to close a thread? also Iacobus1983 thanks for your answer, i tried compiling multiple times but it didn't work before – gorsedh Feb 21 '22 at 21:52

2 Answers2

0

Open with sumatra. See the bookmarks and the colored links in the table of content.

Used

\definecolor{mylinks}{rgb}{0.0, 0.28, 0.67} 
    \usepackage[bookmarksnumbered, backref = true]{hyperref}    
    \hypersetup{colorlinks=true,linkcolor=mylinks,urlcolor=mylinks,citecolor=mylinks}

enter image description here

This is a simplified code (without the \input). Must be compiled twice to generate the TOC.

\documentclass[12pt,a4paper]{book}
\usepackage[italian]{babel}
\usepackage[T1]{fontenc}
\usepackage{newlfont}
\usepackage{xcolor}
\usepackage{graphicx}

\graphicspath{ {immagini/} } \textwidth=450pt\oddsidemargin=0pt

\usepackage{cite}

\definecolor{mylinks}{rgb}{0.0, 0.28, 0.67} \usepackage[bookmarksnumbered, backref = true]{hyperref}
\hypersetup{colorlinks=true,linkcolor=mylinks,urlcolor=mylinks,citecolor=mylinks}

\begin{document} \begin{titlepage} % % % UNA VOLTA FATTE LE DOVUTE MODIFICHE SOSTITUIRE "RED" CON "BLACK" NEI COMANDI \textcolor % % \begin{center} {{\Large{\textsc{Alma Mater Studiorum $\cdot$ Universit`a di Bologna}}}} \rule[0.1cm]{15.8cm}{0.1mm} \rule[0.5cm]{15.8cm}{0.6mm} \\vspace{3mm}

        {\small{\bf Scuola di Scienze \\ 
                Dipartimento di Fisica e Astronomia\\
                Corso di Laurea in Fisica}}

    \end{center}

    \vspace{23mm}

    \begin{center}{\LARGE{\bf TITOLO TESI}\\
    }\end{center}

    \vspace{50mm} \par \noindent

    \begin{minipage}[t]{0.47\textwidth}
        %
        % INSERIRE IL NOME DEL RELATORE CON IL RELATIVO TITOLO DI DOTTORE O PROFESSORE
        %
        {\large{\bf Relatore: \vspace{2mm}\\\textcolor{black}{
                    Prof./Dott. Nome Cognome}\\\\
                \textcolor{black}{
                    \bf Correlatore: (eventuale)
                    \vspace{2mm}\\
                    Prof./Dott. Nome Cognome\\\\}}}
    \end{minipage}
    %
    \hfill
    %
    \begin{minipage}[t]{0.47\textwidth}\raggedleft \textcolor{black}{
            {\large{\bf Presentata da:
                    \vspace{2mm}\\
                    %
                    % INSERIRE IL NOME DEL CANDIDATO
                    %
                    Nome Cognome}}}
    \end{minipage}

    \vspace{40mm}

    \begin{center}
        %
        % INSERIRE L'ANNO ACCADEMICO
        %
        Anno Accademico \textcolor{black}{ 2021/2022}
    \end{center}

\end{titlepage}
\chapter*{Abstract}
Abstract goes here

%\chapter*{Dedication}
%To mum and dad

%\chapter*{Declaration}
%I declare that..

%\chapter*{Acknowledgements}
%I want to thank...

\tableofcontents

\chapter{Introduzione}

% \input{capitoli/introduzione}

\chapter{Modello Standard}

% \input{capitoli/sm}

\chapter{Analisi Dati}
\section{Modelli di Fit}

% \input{capitoli/analisiDati}

\chapter{Chapter Four Title}

% \input{capitoli/capitolo03}

\chapter{Conclusion}

% \input{capitoli/conclusioni}

\appendix
\chapter{Appendice}

% \input{capitoli/appendice} %
% \bibliographystyle{IEEEtran} % \bibliography{./biblio}

\end{document}

Simon Dispa
  • 39,141
0

Add these

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
gorsedh
  • 15