# Reference to subequation forces serif font; how to work around?

I'm using the subequations environment in a book in which some text is in sans serif font. When I have a reference to a subequation, the reference comes out in a serif font, even if the surrounding text is sans. Below is a minimal example that demonstrates the problem.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{subequations}
\begin{align}
1+1&=2 \label{foo}\\
2+2&=4
\end{align}
\end{subequations}
\textsf{See equation \eqref{foo}.}
\end{document}


Seems like a bug to me. Can anyone suggest how to work around this problem?

-
You could use \renewcommand{\eqref}[1]{(\ref{#1})} after loading amsmath. – cfr Jan 24 '14 at 3:01

It's a feature, not a bug and it will happen with all the numbered environments for equations, not only subequations, if amsmath is loaded and \eqref is used. The responsible for this behaviour is a \normalfont in the definition of \maketag@@@ in amsmath.sty:

\def\maketag@@@#1{\hbox{\m@th\normalfont#1}}


if you want to suppress this feature, you can redefine \maketag@@@:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\def\maketag@@@#1{\hbox{\m@th#1}}
\makeatother

\begin{document}
\begin{subequations}
\begin{align}
1+1&=2 \label{foo}\\
2+2&=4
\end{align}
\end{subequations}
\textsf{See equation \eqref{foo}.}
\end{document}


Notice, however, that this redefinition will make the string used in the cross-reference to inherit the font attributes of the surrounding text; this can be inconvenient; think for, for example, when italics are used. In fact, since the equation is labelled using roman font, the cross-references should be kept using the roman font. That's one of the reasons (I believe) why the package author(s) decided to add \normalfont in the first place.

-
Thanks for the speedy answer! Can you explain what this is doing and whether it would have other side-effects? – Ben Crowell Jan 24 '14 at 2:58
@BenCrowell I was doing exactly that. Please see my updated answer. – Gonzalo Medina Jan 24 '14 at 2:59
@GonzaloMedina -- the package authors didn't consider the possibility that sans serif would be the style in which an equation reference would be embedded, since sans serif is almost never used in ams publications in a context which could contain such a reference. maybe that decision (based on traditional specifications) should be reexamined. – barbara beeton Jan 24 '14 at 6:06
It seems to me that this is clearly a bug, not a feature. If I have a document in which subequations aren't used, then I get behavior A, in which equation references everywhere match the serif or sans-serif style of the surrounding text. If I introduce a subequation, then behavior A continues to apply to all equations except for the subequation, which exhibits new behavior B: references to it don't agree with surrounding sans serif text. It may be possible to argue that B is a better choice than A, but it is clearly wrong to have sometimes A and other times B. – Ben Crowell Jan 26 '14 at 0:45
Oops, more careful testing shows that my comment above is completely wrong. Behavior B always happens, and this is nothing to do with subequations. – Ben Crowell Jan 26 '14 at 1:18

I think you could also redefine \eqref in a way which would not result in an italicised reference, but would pick up the current font family and series. That is, you'd get:

The code:

\documentclass{article}
\usepackage{amsmath}
\renewcommand{\eqref}[1]{\upshape(\ref{#1})}
%\renewcommand{\eqref}[1]{(\ref{#1})}% uncomment this line if you want references to use the font shape of the surrounding text, as well as the series and family (and you can comment/remove the previous line in that case)
\begin{document}
\begin{subequations}
\begin{align}
1+1&=2 \label{foo}\\
2+2&=4
\end{align}
\end{subequations}

\textsf{See equation \eqref{foo}.}

\textit{See equation \eqref{foo}.}
\end{document}


EDIT: Note that I'm not recommending this for the reasons given by Gonzalo Medina. I may lend you my axe without thinking you ought to chop your barn up for firewood.

-