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


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

\section{This is a section}

    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}$




  • 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

This issue is now fixed in version 12.2 of bidi package which is now on CTAN. Please for future, do not report bidi issues here; it is very hard for us to search Internet and hunt down who has got problem and who has not. Instead, please do as stated in README file of bidi package.


I don't know why it happens, but enclosing \ref in \mbox seems to cure the disease:


it seems that the combination of hyperref and bidi doesn't like xrefs in math. you can \usepackage{amstext} and then \text{\ref{...}}.

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