# Internal hyperref links do not work with res.cls

I am using the popular res.cls for my resume (CTAN Link)

I would like to put internal links in my file. However, the following does not successfully place the internal links:

\documentclass{res}

\usepackage{hyperref}

\begin{document}

\section{Section 1}
\label{sec:part1}

\section{Section 2}
\label{sec:part2}

\end{document}


However, if I use a built-in .cls the links are placed successfully:

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\section{Section 1}
\label{sec:part1}

\section{Section 2}
\label{sec:part2}

\end{document}


What modifications need to be made to the .cls file in order for this to behave as expected?

• res is an outdated class and popular is arguable ;-) Don't use it. The main cause is that res explicitly states \nofiles in the class file, which is totally absurd and leaves no user control – user31729 Jun 24 '17 at 19:41

res.cls is a strange class and should not be used, in my point of view. It has the explicit\nofiles statement in the class file, which prevents the generation of the auxiliary files such as .aux, which is needed desperately by hyperref.

Another issue is that \section is effectively redefined, so there is no counter used at all, i.e. \refstepcounter and \label is actually useless :-(

One possible solution (amongst not using res.cls) is to say \let\nofiles\relax before \documentclass{res}.

Using something like

\makeatletter
\@fileswtrue
\makeatother


does not solve the problem, since \protected@write is redefined within \nofiles to write to the terminal always, so nothing would be gained here really.

The \label issue can be solved by prepending the \section command with \phantomsection.

\let\nofiles\relax
\documentclass{res}
\usepackage{etoolbox}
\usepackage{hyperref}

\pretocmd{\section}{\phantomsection}{}{}
\begin{document}

\section{Section 1}
\label{sec:part1}

\clearpage
\section{Section 2}\label{sec:part2}


Much cleaner ways: Use \hyperlink or cleveref or \nameref.