1

I am trying to use hyperref package with my thesis, I put here a simplified version:

\documentclass[a4paper,twoside,12pt,notitlepage,openright]{article}
\usepackage[ansinew]{inputenc}
\usepackage[dvips,dvipdfmx]{graphicx} %[dvips] to used with .eps figures
\usepackage{bmpsize} % insert pdf figures
\usepackage{natbib}
\usepackage{lastpage}   % page count
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[english]{babel}
\usepackage[intoc]{nomencl} % including table of content
\usepackage{ifthen}
\usepackage[hmargin=3.0cm,vmargin=3.6cm]{geometry} % setting marginals
\usepackage{fancyhdr,extramarks}  % header ja footer manipulation
\usepackage{times}  % to change font to times
\usepackage{setspace} % for linespacing
\usepackage{color,soul} % for highlighting text
\usepackage[version=4]{mhchem} % for chemical formulas
\usepackage{url} % fix compilation error for url used in the references
\usepackage{gensymb} % degree celcius
\usepackage{enumerate} %use roman labels in enumerate

\singlespacing

\pagestyle{fancy}
\fancyhf{}% clearing the header and footer
\fancyhead[LE,RO]{\bfseries\thepage}    % page number to header
\fancyhead[LO]{\nouppercase{\bfseries\rightmark}}     %
\fancyhead[RE]{\nouppercase{\bfseries\leftmark}}%

\renewcommand\sectionmark[1]
 {\markboth{\thesection\ #1}{}}         % section name to header
\renewcommand\subsectionmark[1]
 {\markright{\thesubsection\ #1}}       % subsection name to header
\renewcommand{\headrulewidth}{0.5pt}    % ruler thickness between head and body
\renewcommand{\footrulewidth}{0pt}      % no ruler between body and footer

\setlength{\nomitemsep}{-\parsep}   % removing default extra skip between entries at nomenclature

\numberwithin{equation}{section}    % equation numbers with section numbers
\numberwithin{table}{section}       % table numbers with section numbers
\numberwithin{figure}{section}      % figure numbers with section numbers

% makeindex command needs to run at command prompt to create nomenclature list file
\makenomenclature % makeindex main_v2.nlo -s nomencl.ist -o main_v2.nls
%\bibpunct{(}{)}{;}{a}{,}{,}%

\usepackage{hyperref}

\begin{document}

\pagestyle{empty}
\include{abstract}
\addtocontents{toc}{\contentsline{section}{Abstract}{}{}}%

\end{document}

Where abstract.tex is the following:

\section*{Abstract}

\textbf{My name}\\
\textbf{Title}\\
Year 2019\\
\pageref{LastPage} pages\\
XXXXXX\\
Cool dissertation\\
ISBN XXXX, ISBN XXXX (PDF), ISSN XXXXXX\\

something\\

more\\

about it.\\

Keywords: this, that, this that and that\\
UDC: XXXX : XXXX : XXXX\\

At first, adding \usepackage{hyperref} was returning an error because the number of arguments in \contentsline had to be changed from 3 to 4 (or to 5 as I saw recommended somewhere). After including another {}, it now returns the following error:

!Incomplete \iffalse; all text was ignored after line 53
<inserted text>
\fi
The file ended while I was skipping conditional text.
! Emergency stop

I can see this question was already asked \usepackage{hyperref} causing incomplete \iffalse error but no answer provided.

  • 1
    Don't use two driver commands ` \usepackage[dvips,dvipdfmx]{graphicx}` That doesn't make sense. You can either compile with latex and dvips or with latex and dvipdfmx but not with both on the same time. (and if you use pdflatex both options are wrong, then better use no option at all). – Ulrike Fischer Aug 19 '18 at 11:15
  • Why would you want to add the abstract to the table of contents without a page number? By the way, it should be \input{abstract} or you'd get an automatic page break. – egreg Aug 19 '18 at 14:07
2

You need to protect the \contentsline command, and better put it directly after the section command so that it points to the right place:

\phantomsection
\section*{Abstract}
\addtocontents{toc}{\protect\contentsline{section}{Abstract}{}{}{}}%
  • Do you mean adding \phantomsection before \include{abstract}? – Mariana Aug 19 '18 at 11:33
  • put everything inside the include. – Ulrike Fischer Aug 19 '18 at 12:05
  • I am sorry, your answer is still not clear. You mean inside the abstract.tex file? – Mariana Aug 19 '18 at 12:09
  • Now it works, I have added the commands above in the abstract.tex file, instead of the main file. Thanks :) – Mariana Aug 19 '18 at 13:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.