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.

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}

\begin{equation}
    a = b \label{eq} 
\end{equation}

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

closed as too localized by Speravir, Kurt, Werner, Thorsten, Andrew Swann Apr 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

3 Answers 3

up vote 2 down vote accepted

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.

share|improve this answer

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

$\mbox{\ref{sec}}$
share|improve this answer

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

share|improve this answer

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