Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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