I have some problem with my PhD thesis, in particular with the Table of Contents.
My preface consists in many different environments (defined by a custom class) containing the abstract, the acknowledgements, the statement of originality, etc and with pages numbered with roman numbers.
Everyone of this environment has its own definition and format with the command \addcontentsline{toc}{chapter} to list it in the ToC.

And this work properly.

Now I would like to group all these ToC entries into a fictional part called "Preface", the main chapters of my thesis under "Main chapters" and so on with the appendixes and some final stuff, so I added \addcontentsline{toc}{part}{Preface} at the very beginning and \addcontentsline{toc}{part}{Main chapters} before all the actual content of my thesis.
Unfortunatly, the result is a bit strange, as you can see in the attached picture, in particular the hyperref part work properly while the ToC doesn't.
A snippet of the code I'm using is:

\tableofcontents            % generate and include a table of contents
% end roman page numbering
\addcontentsline{toc}{part}{Main chapters}
%now include the files of latex for each of the chapters etcbut I prefered to insert it there

with the romanpages environment defined as:


As you can see, I tried to play around a bit with \phantomsection, but without any results.
Any idea on how to fix this?


P.S. the code included is not an MWE and I'm not supplying it because I cannot really reproduce the problem with a simple example

enter image description here

  • 1
    Don't use \include, use \input instead. – Ulrike Fischer Apr 17 at 17:02
  • unrelated but you can simplify setcounter{page}{1} \renewcommand{\thepage}{\roman{page}} to \pagenumbering{roman} – David Carlisle Apr 17 at 17:58
  • @UlrikeFisher can you add more details about this choice? Reading around, to me, include seems better because it will not compile not modify stuff.... (and by the way, I'm also using that command in the preamble or in child files) – Jacopo Remondina Apr 18 at 21:17
  • @DavidCarliste thanks for the tip, but that definition is in my class file, so I prefer to not change it – Jacopo Remondina Apr 18 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.