4

I have some hyperlink problems in a PDF that I appear to be able to solve by adding \hypersetup{naturalnames=true} to my .tex file. What might go wrong by adding this command? The text of my paper doesn't appear to have changed, and the links that went to the wrong places before now go to the right places, but might some other links go to the wrong places without warning?

I don't have a short example to show; I'm just wondering if there are any common problems to look out for.

MSC
  • 2,722

1 Answers1

5

To cite the hyperref manual:

"Anything which can be referenced advances some counter; we overload this to put in a hypertext starting point (with no visible anchor), and make a note of that for later use in \label. This will fail badly if \theH<name> does not expand to a sensible reference. This means that classes or package which introduce new elements need to define an equivalent \theH<name> for every \the<name>. We do make a trap to make \theH<name> be the same as \arabic{<name>}, if \theH<name> is not defined, but this is not necessarily a good idea. Alternatively, the naturalnames option uses whatever LaTeX provides, which may be useable. But then its up to you to make sure these are legal PDF and HTML names. The hypertexnames=false option just makes up arbitrary names." (Emphasis mine)

Apart from the legality of the LaTeX label names used with option naturalnames=true, the labels may not be unique. The following code has broken links with naturalnames=true, but works without this option. You might blame subfig here, but that is something to look out for. However, you will get a warning when naturalnames introduces new problems.

\documentclass{article}

\usepackage{subfig}
% \usepackage[naturalnames=true]{hyperref}     %% does not work
\usepackage{hyperref}                          %% works

\begin{document}
\section{One}

\begin{figure}[ht]
    \subfloat[][]{Ding\label{subfig:11}} \hfill
    \subfloat[][]{Deng\label{subfig:12}}
    \caption{Caption}
\end{figure}

\begin{figure}[ht]
    \subfloat[subfig:21][]{Dong\label{subfig:21}} \hfill
    \subfloat[subfig:22][]{Dung\label{subfig:22}}
    \caption{Caption}
\end{figure}
Subfigures~\ref{subfig:11}, \ref{subfig:12}, \ref{subfig:21}, \ref{subfig:22}.
\end{document}
mafp
  • 19,096