0

I am writting my first Latex document. My document is now 140 pages long and I thought that making the table of contents clickable would be a good idea. I use ShareLatex to compile my code. I imported hyperref package an I found that my code doesn't compile.Specifically, ShareLatex tells me:

"Timed out. Sorry, your compile took too long to run and timed out. This may be due to a large number of high-res images, or complicated diagrams."

If I go to the log tab I only see some overfull and underfull warnings. Now, I use about 20 normal-sized photos and one not too complex diagram. Of course, if I comment the \usepackage{hyperref} the whole document gets loaded in less than 7 seconds. I searched a lot and find many things to take into account when importing hyperref. I read the manual and the question Which packages should be laoded after hyperref instead of before? but I cant make it work. This is how my import header looks like:

%\documentclass[draft]{report}
\documentclass{report}
\usepackage[noend]{algpseudocode}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage{calculator}
\usepackage[spanish]{babel}
\usepackage{csquotes}
\usepackage{verbatimbox}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{listings}
\usepackage{moreverb}
\usepackage{fancyhdr}
\usepackage{fancyvrb}
\usepackage{enumitem}
\usepackage{textcomp}
\usepackage{wrapfig}
\usepackage[headheight=110pt]{geometry}
\AtBeginDocument{%
\let\AtBeginDvi\OrgAtBeginDvi
}

\usepackage{subfiles}
\usepackage{multicol}
\usepackage[toc,page]{appendix}
\usepackage{url}
\usepackage{tikz}
\usepackage{framed}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{longtable}
%% Set some local commands and colors
\usepackage{colortbl}
\definecolor{green}{rgb}{0.1,0.1,0.1}
\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt,
maxnames=99,
maxalphanames=5
]{biblatex}
\addbibresource{bibliografia.bib}
\graphicspath{{images/}{../images/}}
\newcommand{\specialcell}[2][c]{
    \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}
}
\renewcommand{\figurename}{Figura}
\renewcommand{\lstlistingname}{Código}
\renewcommand\lstlistlistingname{Listado de Códigos}

\usepackage{lastpage}
\usepackage{pgfgantt}

%\usepackage{hyperref} %WHERE SHOULD I PUT THIS LINE?

\usepackage{tabularx}
\usepackage{algorithm}
\renewcommand{\listofalgorithms}{ 
  \begingroup 
    \listof{algorithm}{Listado de Pseudocódigos} 
  \endgroup 
}

\begin{document}

I updated my main.tex like runartrollet suggested. However it still doesn't compile. This is how my whole main.tex looks like now:

\documentclass[%
%draft,%
]{report}

\usepackage[noend]{algpseudocode}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[headheight=110pt]{geometry}
\usepackage[toc,page]{appendix}
\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt,
maxnames=99,
maxalphanames=5
]{biblatex}
\usepackage{%
blindtext,
calculator,
csquotes,
verbatimbox,
graphicx,
mathtools, %(replaces amsmath, and fixes a few errors in it)
listings,
moreverb,
fancyhdr,
fancyvrb,
enumitem,
textcomp,
wrapfig,
subfiles,
multicol,
url,
tikz,
framed,
xcolor,
booktabs,
longtable,
colortbl,
lastpage,
pgfgantt,
tabularx,
algorithm,
hyperref
}
\AtBeginDocument{%
\let\AtBeginDvi\OrgAtBeginDvi
}
%% Set some local commands and colors
\definecolor{green}{rgb}{0.1,0.1,0.1}
\addbibresource{bibliografia.bib}
\graphicspath{{images/}{../images/}}
\newcommand{\specialcell}[2][c]{
    \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}
}
\renewcommand{\figurename}{Figura}
\renewcommand{\lstlistingname}{Código}
\renewcommand\lstlistlistingname{Listado de Códigos}


\renewcommand{\listofalgorithms}{ 
  \begingroup 
    \listof{algorithm}{Listado de Pseudocódigos} 
  \endgroup 
}
\begin{document}


\begin{titlepage}
\begin{center}
\vspace*{-1in}
\begin{figure}[htb]
\begin{center}
\vspace*{1.6in}
\includegraphics[width=8cm]{uc3m.png}
\vspace*{0.6in}
\end{center}
\end{figure}
\begin{large}
Trabajo de Fin de Grado\\
\end{large}
\vspace*{0.2in}
\begin{Large}
\textbf{Valoración de startups\\con\\ Aprendizaje Automático} \\
\end{Large}
\vspace*{0.3in}
\vspace*{0.3in}
\rule{80mm}{0.1mm}\\
\vspace*{0.1in}
\begin{large}

\end{large}
\end{center}

\end{titlepage}
\pagestyle{fancy}
\lhead{\includegraphics[scale=1]{encabezado.jpg}}

\subfile{ackstract}

\tableofcontents

\listoffigures
\listoftables
\lstlistoflistings
\begingroup
\let\clearpage\relax
\listofalgorithms
\endgroup
\clearpage
\part{Introduction}
    \chapter{Presentation, motivation and objectives}
    \subfile{chapters/intro}
\part{Teoría y Estado del Arte}
    \chapter{Valoración}
    \subfile{chapters/ea_valoracion}
    \chapter{Aprendizaje Automático}
    \subfile{chapters/ea_inf}    
    \chapter{Metodologías}
    \subfile{chapters/metodologia}
    \chapter{Herramientas}
    \subfile{chapters/herramientas}
\part{Contrucción del modelo}
    \chapter{Determinando la actividad de la empresa}
    \subfile{chapters/p_sectores_industrias}
    \chapter{Tasa descuento y riesgo}
    \subfile{chapters/rwg}
    \chapter{Flujos de caja libres}
    \subfile{chapters/p_flujos}
    \chapter{Aplicación del modelo}
    \subfile{chapters/aplicacion}
    \chapter{Despliegue}
    \subfile{chapters/integrate}
\part{Conclusiones}
    \subfile{chapters/conclusiones}
\printbibliography[
heading=bibintoc,
title={Referencias}
]
\begin{appendices}
\chapter{Listado de frecuencias de industrias}
\subfile{appendices/listado_frecuencias_industrias}
\chapter{Distribuciones estadísticas}
\subfile{appendices/distribuciones}
\chapter{Planificación}
\subfile{appendices/planificacion}
\end{appendices}
\clearpage
\end{document}

I exported my project to Overleaf which gives me more feedback:

./main.out:92:
Missing \endcsname inserted.
<to be read again> 
                   \unhbox 
l.92 ...tor \futurelet \textbf  ndice.alph1.Alph3}

And I could also get the logfile:

6
  • 5
    "does not compile" gives no clues, what was the error message? If I add \end{docuemnt} so your example is a document it runs without error, please fix the example so that it shows the error you get. Jun 3 '16 at 20:06
  • You are totally right. Unfortunately, ShareLatex doesn't give me much feedback. I updated my post. One the other hand, my problem is that I can't compile the code with the line \usepackage{hyperref} uncommented and I put the \begin{document} just to show where my doc starts. Thanks Jun 3 '16 at 21:14
  • If you post an error free document and do not state what error you get in your real document, I am sorry but no one can possibly help. I am sure you can get the tex log from sharelatex Jun 3 '16 at 21:23
  • what is the intention of \AtBeginDocument{% \let\AtBeginDvi\OrgAtBeginDvi } ??? It breaks \AtBeginDvi so may break some packages Jun 3 '16 at 21:33
  • I honestly don't remember. In fact, I have deleted it and everything stays the same. I added a log file. Jun 3 '16 at 22:14
1

Fixing your compile problem (Question was edited with a new problem)

After going through you code, I renamed these lines(subfiles are commented out, only becouse I don't have them, just comment them in):

\begin{appendices}
\chapter{Listado de frecuencias de industrias}
%\subfile{appendices/listado_frecuencias_industrias}
\chapter{Distribuciones estadísticas}
%\subfile{appendices/distribuciones}
\chapter{Planificación}
%\subfile{appendices/planificacion}
\end{appendices}

into these lines, where the enviroment appendices is changed to \appendix:

\appendix
\chapter{Listado de frecuencias de industrias}
%\subfile{appendices/listado_frecuencias_industrias}
\chapter{Distribuciones estadísticas}
%\subfile{appendices/distribuciones}
\chapter{Planificación}
%\subfile{appendices/planificacion}

After that, it compiles fine here (after removing code with graphics I don't have, inserting \documentclassand commenting out all other subfiles I also don't have.)

I notice you use the \begin{center},\end{center}, you should replace it by a simple \centering, to avoid some spacing issues. See When should we use \begin{center} instead of \centering?

Also, in the comments it was mentioned that you have some code that you no longer remember what is for, and couldn't find that removing it really changed anything. You should comment your code more. Especially a special code like that, I have no idea what it does. Comment when adding new and unfamiliar packages also. It really saves you a lot of time and trouble in the long run.

Fixing the hyperref problem (mentioned first)

Here is an working example with your code. The table of contents are clickable.

Your code seems to be working fine, just after a few alterationt. I didn't really add much to your code, just a simple \section, \tableofcontents and \end{document}. Also, I uncommented the \usepackage{hyperref}. As you have already read the Which packages should be loaded after hyperref instead of before?, you probably know which packages would interfere. Most of the time it should be last, with just a few packages that should be placed after, like cleverref. The linked post can elaborate.

Also, at the top, you used a whole commented out \documentclass with options, with what I'm guessing to switch between draftand final quickly. This could be made easier by using one line per option with a , at the end, like below. Then you simply comment out that line, to disable that option. You could also do this for loading packages, and I have made here an edit which shows this. It is now much less code, and more information, easily commented out.

\documentclass[%
%draft,%
]{report}

\usepackage[noend]{algpseudocode}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[headheight=110pt]{geometry}
\usepackage[toc,page]{appendix}
\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt,
maxnames=99,
maxalphanames=5
]{biblatex}
\usepackage{%
blindtext,
calculator,
csquotes,
verbatimbox,
graphicx,
mathtools, %(replaces amsmath, and fixes a few errors in it)
listings,
moreverb,
fancyhdr,
fancyvrb,
enumitem,
textcomp,
wrapfig,
subfiles,
multicol,
url,
tikz,
framed,
xcolor,
booktabs,
longtable,
colortbl,
lastpage,
pgfgantt,
tabularx,
algorithm,
hyperref
}
\AtBeginDocument{%
\let\AtBeginDvi\OrgAtBeginDvi
}
%% Set some local commands and colors
\definecolor{green}{rgb}{0.1,0.1,0.1}
\addbibresource{bibliografia.bib}
\graphicspath{{images/}{../images/}}
\newcommand{\specialcell}[2][c]{
    \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}
}
\renewcommand{\figurename}{Figura}
\renewcommand{\lstlistingname}{Código}
\renewcommand\lstlistlistingname{Listado de Códigos}


\renewcommand{\listofalgorithms}{ 
  \begingroup 
    \listof{algorithm}{Listado de Pseudocódigos} 
  \endgroup 
}

\begin{document}
\tableofcontents
\clearpage
\section{Foo}   
\end{document}
3
  • Thanks a lot for the advice. I compiled your example creating a new project in ShareLatex and it works. However, If I use it with my project it still doesn't work. I updated the post with my main.tex in case its helpful. Jun 3 '16 at 21:29
  • Found your problem. See top of answer.
    – Runar
    Jun 4 '16 at 0:00
  • @runartrollet: Although it does compile, appendix is not an environment, but a regular command (switch), i.e. \appendix
    – user31729
    Jun 4 '16 at 4:18

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.