I know other people have asked this question but having scanned through the answers there seems to be two solutions: compiling 3 or 4 times and trying out some snippets of code involving the \markboth command. I have tried both and can't seem to fix it.

It seems to me (with my superficial understanding of Latex) that this is a problem of forward referencing and the more you compile the more accurate the pointers become. I re-compiled up to 7 times and couldn't get this problem to go away.

Here's my master file where I call every other component:

\documentclass[12pt, a4paper,twoside]{./a4LaTex/tesi_upf}
\input{Latex/Macros/Macrofile}
\usepackage[latin1]{inputenc}
\usepackage[english,french]{babel}
\usepackage{textgreek} %%%%% greek letters in text mode
\usepackage{fixltx2e} %%%%%% sub/superscript type face in text mode
\usepackage[a4paper]{geometry}
\usepackage{graphicx}%%%%% including figures
\usepackage[Bjarne]{fncychap}%%%%% fancy chapter names
\pagestyle{plain} %UPF DONT CHANGE

\usepackage{makeidx}
\usepackage{textcomp}
\usepackage{natbib}%%%%% for bibliography
\renewcommand{\bibsection}{\chapter{\bibname}}
\usepackage{verbatim}
\usepackage[LGR,OT1]{fontenc}%%%%% font
\usepackage{epigrafica}%%%%% font
\usepackage{fancyhdr}
\usepackage{multirow}
\usepackage{fancybox}
\usepackage{lettrine} % for the beginning of chapters
\usepackage{hyphenat} %%%making life easier with hyphenation
\usepackage{amsmath}  %%%making life easier writing math equations
\usepackage{array}
\usepackage{pdfpages}
\usepackage{boxedminipage}
\usepackage{subfigure}
\usepackage{floatrow}
\usepackage{longtable}
\usepackage{pdfpages}  % for inserting PDF files into Latex
\usepackage{morefloats}

\makeindex
\selectlanguage{english}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\hyphenation{biology}
\selectlanguage{english}
\frontmatter % UPF
\maketitle
\clearpage % UPF

% sets line spacing
\renewcommand{\baselinestretch}{1.0}
\baselineskip=18pt

\chapter*{Glossary} % top level followed by section, subsection
\label{glossary}

\begin{center}
\begin{longtable}{ll}

\caption{List of abbreviations} \label{gloss} \\

%This is the header for the first page of the table...
\hline \hline \\[-2ex]
\multicolumn{1}{l}{\textbf{Abbreviation}} &
\multicolumn{1}{l}{\textbf{Description}} \\[0.5ex] \hline
\\[-1.8ex]

%This is the header for the remaining page(s) of the table...
\multicolumn{2}{c}{{\tablename} \thetable{} -- Continued} \\[0.5ex]
\hline \hline \\[-2ex]
\multicolumn{1}{l}{\textbf{Abbreviation}} &
\multicolumn{1}{l}{\textbf{Description}} \\[0.5ex] \hline
\\[-1.8ex]

%This is the footer for the last page of the table...
\\[-1.8ex] \hline \hline
\endlastfoot

% now the data
AF &  affinity purification\\
AP2 &  apetala 2\\
ARNTL &  aryl hydrocarbon receptor nuclear translocator-like\\
BMAL1 & brain and muscle ARNT-like 1\\
BMP & bone morphogenetic protein\\
BrdU & bromodeoxyuridine\\
C/EBP & CCAAT/enhancer binding protein\\
CLOCK & circadian locomoter output cycles protein kaput\\
ECM & extracellular matrix\\
EGF & epidermal growth factor\\
FGF & fibroblast growth factor\\
HF & hair follicle\\
HT & high-throughput\\
HPLC & high-pressure liquid chromatogrphy\\
IEX-HPLC & ion exchange high-pressure liquid chromatography\\
IF & interfollicular\\
IFE & interfollicular epidermis\\
\end{longtable}
\end{center}
\cleardoublepage

%%%%% List of Figures
\listoffigures
\cleardoublepage

%%%%% List Of Tables
\listoftables
\cleardoublepage

% Define what levels to number in the TOC
\setcounter{secnumdepth}{3} % organisational level that receives a number

\tableofcontents
\markboth{Contents}{\textbf{Contents}}
\cleardoublepage

%%%%% no indentation
\setlength{\parindent}{0pt}

\mainmatter
\pagenumbering{arabic}
\clearpage

\cleardoublepage

%%%%% Bibliography
\bibliographystyle{/Users/kianatoufighi/Dropbox/Thesis/ThesisLatex/BibStyles/jmb}
\bibliography{/Users/kianatoufighi/Dropbox/Thesis/ThesisLatex/BibLib/mylibrary}
\end{document}

• The \phantomsection is missing before each \addcontentsline command, try that
– user31729
Jul 20 '14 at 19:02
• Besides that: Due to the \include statements, your document is not compilable for users here, since content of this included files is not available.
– user31729
Jul 20 '14 at 19:04
• Just for information, except in some very specific cases, compiling twice is enough for references. Once to create the .aux file (containing a sort of index for references and so on) and a second one to read this index and "write" the proper information in the output. Jul 20 '14 at 19:41
• I'll try to edit it into a minimal working example now. Jul 20 '14 at 20:54

With your code the number of the last page of the \listoffigures and the last page of the \listoftables will be shown in the \tableofcontents.
\cleardoublepage