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.

Why doesn't the equation number referral appear within the empheq/array environment ? In this example I left out the formulas within the empheq environment (the problem remains with the formulas added).

\documentclass{article}
\usepackage{amsmath}
\usepackage{empheq}

\begin{document}

\begin{empheq}{align}
\label{eq:1}
\left\{\!\!\begin{array}{l}
\text{An equation reference should appear after the question mark, but doesn't ? \eqref{eq:2}}\\
\text{This doesn't work either : \eqref{eq:2}}
\end{array}\right.
\end{empheq}

I can definitely refer to the equation though, like this : \eqref{eq:2}.

\begin{empheq}{align}
\label{eq:2}
1+1=2
\end{empheq}


It compiles without throwing an error.

\end{document}
share|improve this question
    
You need to compile the document twice. First time a (??) is displayed, upon subsequent run, the equation number will appear. –  Peter Grill Nov 7 '12 at 20:22
    
I did - makes no difference. –  Petoetje59 Nov 7 '12 at 20:24
    
Nothing is displayed, not even the (??). –  Petoetje59 Nov 7 '12 at 20:25
    
And do not remove the temporary files generated during the first run. –  Peter Grill Nov 7 '12 at 20:25
    
I didn't remove anything, as I said, it doesn't throw up any error, but does not work. –  Petoetje59 Nov 7 '12 at 20:26
show 4 more comments

2 Answers

up vote 2 down vote accepted

The problem goes away if you use (\ref{whatever}) in place of \eqref{whatever}. I have no idea why this happens, though.

share|improve this answer
    
Works, but does not retain the brackets, but these can be added separately. THX. –  Petoetje59 Nov 7 '12 at 21:13
add comment

The main problem is that empheq redefines \maketag@@@ because it need to separate the display from the eqn numbers. But \eqref also make use of this macro to typeset the reference to an eqn numbers. The fix below seem to do the trick and will be build into the next empheq release

\makeatletter
\MHInternalSyntaxOn
\renewenvironment{empheq}[2][]{%
  \let\savedmaketag\maketag@@@
  \renewcommand\eqref[1]{\textup{%
      \let\maketag@@@\savedmaketag%
      \tagform@{\ref{##1}}}%
  }
  \setkeys{EmphEqEnv}{#2}\setkeys{\EQ_options_name:}{#1}%
  \EmphEqMainEnv}{\endEmphEqMainEnv}
\MHInternalSyntaxOff
\makeatother
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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