Tell me more ×
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
And is \ref -- which essentially returns a text-mode contents -- supposed to work in math mode? – tohecz Feb 28 at 0:21
@tohecz It does work if no extra packages are loaded. Is that just a fluke? – Ari Brodsky Feb 28 at 0:26

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

3 Answers

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.