# Figure reference problems using hyperref

My problem seems to be simple although I could not find any solutions for it yet. I am writing my thesis in LaTeX, but I am totally new to this type of language.

I am trying to reference a figure as:

(see Figure~\ref{fig:transistor1})


whereas the figure is defined right after the reference as:

\begin{figure}[htb]
\centering
\includegraphics[width=0.4\linewidth]{./_pic/transistor1}
\caption[The first transistor]{The first point-contact transistor developed by Bell Laboratories}
\label{fig:transistor1}
\end{figure}


During compilation, I get the error "Paragraph ended before \Hy@setref@link was complete", and of course in the compiled pdf there is not any number after the word Figure, moreover the ) symbol is also missing.

I've tried changing the order of the figure and its reference, leaving the () marks but nothing helped.

I am waiting for your help guys, and thank you in advance :)

Update: MWE:

\documentclass[a4paper,12pt,twoside,openright]{report}

\begin{document}
\chapter{MEMS technology}

\ref{fig:transistor1}

\begin{figure}[htb]
\centering
\caption[The first transistor]{The first point-contact transistor developed by Bell Laboratories}
\label{fig:transistor1}
\end{figure}

\end{document}


Now if you compile this without the hyperref package, than with it, you can get the same error. If you compile again, the error disappears in the MWE (however in the whole document the error stays).

Update#2: Now I have managed to find the proper MWE, the problem occours when the \selectlanguage command is used:

\documentclass[a4paper,12pt,twoside,openright]{report}
\usepackage[british,german,hungarian]{babel}

\begin{document}
\selectlanguage{british}
\chapter{MEMS technology}

\ref{fig:transistor1}

\begin{figure}[htb]
\centering
\caption[The first transistor]{The first point-contact transistor developed by Bell Laboratories}
\label{fig:transistor1}
\end{figure}

\end{document}


• It's difficult to say. Perhaps delete the .aux and try again to compile. – Werner Mar 7 '14 at 15:03
• Take just your reference and figure code above, put it in a new document, and see if that compiles (you'll either need to comment out the \includegraphics command, or add the graphicx package). If that works, the problem stems from something else in your document. After you've done that, build a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Mike Renfro Mar 7 '14 at 15:05
• With \autoref there is no such error, but it is not what I would want to have. – AdamNagy Mar 7 '14 at 15:54

Package hyperref with package nameref changes the internal data format of the \label data, because they need additional data. Therefore errors can be triggered, if the data in the .aux file is written by a different package combinations, especially with or without hyperref/nameref.
• In this case, the error can be ignored, a new .aux file is written and the next LaTeX run should be fine.
• Or delete the auxiliary files, if hyperref/nameref (or some other packages) are added or removed.