# \ref doesn't work in math mode if hyperref and bidi packages are loaded [closed]

Is \ref supposed to work in math mode? If hyperref and bidi are loaded, it generates errors:

\documentclass{article}
\usepackage{hyperref}
\usepackage{bidi}
\begin{document}

Testing labels with \verb+hyperref+ and \verb+bidi+.

\section{This is a section}
\label{sec}

$$a = b \label{eq}$$

In text mode everything works fine.  Referencing equation~\ref{eq} in section~\ref{sec}.

But if we try to do it in math mode, we get errors:  $\ref{eq}$

$\ref{sec}$

$\ref{eq}$

$\ref{sec}$

\end{document}
-

## closed as too localized by Speravir, Kurt, Werner, Thorsten, Andrew SwannApr 5 '13 at 7:18

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

And is \ref -- which essentially returns a text-mode contents -- supposed to work in math mode? –  yo' Feb 28 '13 at 0:21
@tohecz It does work if no extra packages are loaded. Is that just a fluke? –  Ari Brodsky Feb 28 '13 at 0:26

$\mbox{\ref{sec}}$